Liste des Groupes | Revenir à cl c |
On 11/12/2024 16:51, Janis Papanagnou wrote:I don't think anyone has ever disagreed that you can write "if" statements with "else" in C in a way that is confusing or unclear to human readers. (But it still has fixed and unambiguous meaning to the compiler.)On 11.12.2024 17:47, David Brown wrote:So here you finally acknowledge there may be ambiguity from a human perspective.On 11/12/2024 17:30, Janis Papanagnou wrote:>On 11.12.2024 09:43, Ike Naar wrote:>On 2024-12-09, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:>An unambiguous grammar is something quite essential; how would you>
parse code if it were ambiguous?
Here's an ambiguity in the C grammar:
>
[...]
>
The following selection-statement is grammatically ambiguous:
>
if (E1) if (E2) S1 else S2
Yes, the dangling else is a common ambiguity in many programming
languages.
>
That's why I prefer languages with syntaxes like in Algol 68 or
Eiffel (for example).
It is easy to avoid in a C-like language - simply require braces on "if"
statements, or at the very least, require them when there is an "else"
clause.
Yes, sure. But, I can't help, it smells like a workaround.
>Most C coding standards and style guides make that requirement>
- not because the C compiler sees it as ambiguous, but because humans
often do. (Or they misinterpret it.)
Yes, true. (We had that in our standards, too.)
But when I try to make that very point, it's me making up unrealistic examples; I'm being deliberately obtuse; I clearly find things confusing that no one else has a problem with; or you make snarky comments like this:Sure.
"I mean, if you get confused by an unambiguous syntaxes already,It was a totally different point. It is extraordinary that you can't see that.
what do you think happens with people if they have to program
in or understand an ambiguous language!"
It's astonishing how I have to fight across a dozen posts to back up my point of view (you even specifically said you didn't recognise my point).
And yet here: somebody makes that very same point, and you merely say:
"Yes, true."
It really is extraordinary.
Les messages affichés proviennent d'usenet.