Possible enhancement: Concise return statements

Walter Bright newshound2 at digitalmars.com
Mon Aug 15 12:00:03 PDT 2011


On 8/15/2011 3:54 AM, Timon Gehr wrote:
> 'When the last ExpressionStatement in a function body is missing the ';', it is
> implicitly returned.'

This has been proposed several times before, it was also proposed for C++0x. The 
difficulty is it makes having a ; or not substantially alter the semantics. The 
history of these languages is that the presence or absence of ; can be hard to 
spot, as in:

    for (int i = 0; i < 10; i++);
       ... do this ...

which has cost at least one expert developer I know an entire afternoon staring 
at it convinced there was a compiler bug because his loop executed only once.

(And this is why D disallows this syntax.)


More information about the Digitalmars-d mailing list