DIP 1003: remove `body` as a keyword

Timon Gehr via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Fri Nov 25 14:28:06 PST 2016


On 25.11.2016 22:18, Sönke Ludwig wrote:
> Am 25.11.2016 um 12:39 schrieb Timon Gehr:
>> On 24.11.2016 10:24, Kagamin wrote:
>>> I see no ambiguity even if parsing is not greedy.
>>
>> import std.stdio;
>> pragma(mangle,"_D2tt4mainFZ3fooUZv")
>> void foo()in{ assert(true); }{
>>     writeln("Hello World!");
>> }
>> void main(){
>>     static extern(C) void foo()in{ assert(true); }
>>     { foo(); }
>> }
>>
>> Removing contracts, is this this code (printing "Hello World!"):
>>
>> import std.stdio;
>> pragma(mangle,"_D2tt4mainFZ3fooUZv")
>> void foo(){
>>     writeln("Hello World!");
>> }
>> void main(){
>>     static extern(C) void foo();
>>     { foo(); }
>> }
>
> Not without explicitly adding that ";".

?

The point here was to illustrate what the two possible interpretations 
are in terms of code that is compatible with current D. The syntax for 
body-less function declarations with contracts proposed in pull 3611 [1] 
does not require a ';' to be present.

[1] https://github.com/dlang/dmd/pull/3611

The interpretation you are complaining about is in fact the standard 
interpretation without option 3, but with contracts on function 
declarations.


More information about the Digitalmars-d-announce mailing list