<div class="gmail_quote">On Mon, Aug 15, 2011 at 1:57 PM, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On 8/15/11 2:19 PM, Jacob Carlborg wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 2011-08-15 21:00, Walter Bright wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 8/15/2011 3:54 AM, Timon Gehr wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
'When the last ExpressionStatement in a function body is missing the<br>
';', it is<br>
implicitly returned.'<br>
</blockquote>
<br>
This has been proposed several times before, it was also proposed for<br>
C++0x. The difficulty is it makes having a ; or not substantially alter<br>
the semantics. The history of these languages is that the presence or<br>
absence of ; can be hard to spot, as in:<br>
<br>
for (int i = 0; i < 10; i++);<br>
... do this ...<br>
<br>
which has cost at least one expert developer I know an entire afternoon<br>
staring at it convinced there was a compiler bug because his loop<br>
executed only once.<br>
<br>
(And this is why D disallows this syntax.)<br>
</blockquote>
<br>
Can't we always automatically return the last expression, even if it<br>
ends with a semicolon?<br>
</blockquote>
<br></div></div>
Then two semicolons mean return void :o).</blockquote><div><br></div><div>If you want void, you have to use this as your last expression:</div><div><span class="Apple-style-span" style="font-family: monospace; font-size: 13px; line-height: 21px; background-color: rgb(255, 255, 255); ">...- --- .. -..;</span> </div>
</div><br>