DIP 1003 Formal Review
MysticZach via Digitalmars-d
digitalmars-d at puremagic.com
Thu May 25 22:02:33 PDT 2017
On Friday, 26 May 2017 at 01:23:59 UTC, Timon Gehr wrote:
> On 25.05.2017 20:57, MysticZach wrote:
>> struct body {}
>>
>> interface I {
>> int foo(int i)
>> in { assert(i); }
>>
>> body bar();
>> }
>>
>> The ambiguity is fixable by modifying the parser to look ahead
>> after `body` for `{`. Since virtual interface functions are
>> not even allowed to have bodies, if it finds `{`, then `body`
>> should be interpreted as a keyword, and an error issued. In
>> all other cases `body` should be interpreted as an identifier.
>>
>> This is not a hard problem, but it is indeed a semantic
>> ambiguity, so it bears mentioning.
>
> There is no ambiguity, because only one valid interpretation
> exists.
Well the parser needs to be aware of `body` here both as a
keyword and as an identifier, and to use context to determine
which one it is. So to me, that counts as a semantic ambiguity,
one that is resolved trivially, by a single additional token.
It doesn't seem like it lives up to a more generalized fear of
having contextual keywords, unless it's like guy
https://www.youtube.com/watch?v=tgj3nZWtOfA
More information about the Digitalmars-d
mailing list