Am 25.11.2016 um 23:28 schrieb Timon Gehr:
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.

Okay, *that's* the missing piece, thanks for clarifying. I somehow expected that function declarations would always have to end with a semicolon. But admittedly, even then, with my proposal to allow non-block statements for contracts, that would still leave this ambiguity for local function declarations.

The same mechanic unfortunately also makes the "do" suggestion annoying to implement.

Reply via email to