Sujet : Re: question about linker
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 11. Dec 2024, 17:46:50
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vjcfls$1ki9v$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 11.12.2024 16:28, David Brown 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; [...]
>
[ dangling-else sample ]
Given that the resolution is in the "semantics" section rather than the
"syntax" section, it might seem like a grammatical ambiguity. But I
don't think it is, technically - the syntax rules say that the set of
tokens making up "if (E1) if (E2) S1 else S2" are valid syntax. It is
up to the semantics to determine what the code will do here. (And the
semantics are unambiguous.)
I'm a bit ambivalent about that. - Yes, technically it's syntax, it's
syntactically probably correct, and it has a semantical ambiguity that
needs to be resolved. All languages with the dangling-else property do
resolve that. But the syntax could have been defined in a way that such
that a dangling else cannot appear in the first place. (Not in "C" and
descendant languages, of course; that ship has sailed.) - Personally I
thus appreciate languages with if-then-elif-else-fi sorts of syntaxes.
Janis