On 28 November 2012 15:07, tn <span dir="ltr"><<a href="mailto:no@email.com" target="_blank">no@email.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5">On Tuesday, 27 November 2012 at 21:16:41 UTC, Walter Bright wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On 11/27/2012 9:51 PM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
There's another you missed:<br>
enum X = 10;<br>
I would have imagined this would be semantically identical to E.A/E.B,<br>
but the compiler seemed to view this as distinct in my experiments.<br>
</blockquote>
<br>
Those are not enums, they are manifest constants. What distinguishes a manifest constant from, say:<br>
<br>
    const Y = 11;<br>
<br>
is that no storage is allocated for X, and X's address cannot be taken.<br>
</blockquote>
<br></div></div>
What distinguishes manifest constants from literals? Aren't manifest constants just literal aliases? That is, if the following did work<br>
<br>
alias Y = 11;<br>
<br>
wouldn't that be exactly same as<br>
<br>
enum Y = 11;<br>
<br>
Perhaps using "alias" instead of "enum" would make the meaning clearer?<br>
</blockquote></div><br></div><div class="gmail_extra">Interesting concept, but as far as the docs suggest, it's like this:<br></div><div class="gmail_extra">(In fear of dragging a conversation in a bug report to the NG (probably more appropriate here)...)<br>
</div><div class="gmail_extra"><div><br></div></div><div class="gmail_extra">enum E { X = 10 }  // enum definition</div><div class="gmail_extra">enum    { X = 10 }  // anonymous enum<br></div><div class="gmail_extra">enum      X = 10;   // sugar for anon enums with a single value</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">This is how it's documented, and it makes perfect sense to me. I like it. In fact, I found this concept super-endearing when I initially started using D a lot over C++.</div>
<div class="gmail_extra">All X's above should be identical (albeit the first has a named scope), they're all enum values.</div><div class="gmail_extra"><br></div><div class="gmail_extra">E is the type here, it's the only thing that an instance may be created of.</div>
<div class="gmail_extra">X, equally in all cases, is just a constant value. I'm not sure how the language syntax distinguishes it from a literal (I'm not sure why it would have to), but it does seem the compiler distinguishes each of these X's from each other in some cases.</div>