<div class="gmail_quote">On 1 November 2010 16:14, 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 11/1/10 9:09 AM, Gary Whatmore wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Nick Treleaven Wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There's a C++0x proposal for a range-based 'for' statement:<br>
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2930.html" target="_blank">http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2930.html</a><br>
<br>
The upcoming GCC 4.6 C++ compiler changes list support for this:<br>
<a href="http://gcc.gnu.org/gcc-4.6/changes.html" target="_blank">http://gcc.gnu.org/gcc-4.6/changes.html</a><br>
<br>
I think the syntax could be useful for D to shorten and improve on the<br>
status quo a little. Here's the C++ example:<br>
<br>
int array[5] = { 1, 2, 3, 4, 5 };<br>
for (int&  x : array)<br>
   x *= 2;<br>
<br>
Currently D has:<br>
<br>
int array[5] = [1, 2, 3, 4, 5];<br>
foreach (ref x; array)<br>
   x *= 2;<br>
<br>
I think this is better:<br>
<br>
for (ref x : array)<br>
   x *= 2;<br>
<br>
Apart from being 4 chars shorter, I think it looks more natural using the<br>
':' instead of ';'. A lesser benefit is it allows reuse of the 'for'<br>
keyword, making the 'foreach' keyword unnecessary.<br>
<br>
Maybe this would be acceptable for D?<br>
</blockquote>
<br>
No, 1) it's too late to change it. 2) the syntax comes from Java. It would be embarrasing to admit that Java did something right.<br>
<br>
  - G.W.<br>
</blockquote>
<br></div></div>
Java did a lot of things right (be they novel or not) that are present in D, such as reference semantics for classes, inner classes with outer object access etc.<br><font color="#888888">
<br>
Andrei<br>
</font></blockquote></div><br>Why is reference semantics for classes the right thing to do? - Just curious about it, because to me it seems counter intuitive to have to semantics.<br clear="all"><br>-- <br>// Yours sincerely<br>
// Emil 'Skeen' Madsen<br>