Alias Expressions
Paul D. Anderson
paul.d.removethis.anderson at comcast.andthis.net
Mon Apr 23 10:09:43 PDT 2012
On Monday, 23 April 2012 at 14:53:38 UTC, Eldar Insafutdinov
wrote:
> Which brings us to an interesting point that alias and enum
> should be brought together:
>
> alias x = 1;
> alias y = int;
>
> should replace current
>
> enum x = 1;
> alias int y;
>
> respectively. This is makes it a consistent syntax and behavior
> for alias declarations(no reverse order compared to normal
> assignments which is a legacy of C's typedef) and also fixes
> enum
> storage class which name is not relevant anymore.
+1, but I know this has been brought up before. And there's zero
chance it will happen if it doesn't also allow earlier (C/C++/D)
usage.
IMHO, using "enum" as a keyword for declaring constants is
confusing and is a wart on an otherwise elegant* language. I know
that the reason it is used is because under the covers constant
declarations and enums are the same thing. But this is a classic
case of leaving the human interface up to the engineers. Not
everyone (and, in this case, hardly anyone) has the background to
see that.
*Elegance is, of course, highly subjective. And I know that there
are other cases of problematic syntax. It just seems to me that
replacing "enum" is almost painless. (Not replacing, exactly --
"enum" should still work. But there should be an alternative
keyword. Way back when this was first brought up there were
several keywords proposed but none were entirely satisfactory, so
we kind of settled for "enum".)
It makes me want to use:
alias enum constant;
Paul
More information about the Digitalmars-d
mailing list