On 7/8/15 4:14 PM, Tofu Ninja wrote:
On Wednesday, 8 July 2015 at 18:01:36 UTC, Steven Schveighoffer wrote:
In addition, this doesn't work:

alias foo = 2;

I think you are right that that should be allowed, but just out of
curiosity, if that was allowed, then what would the purpose of enum be?

Alias literally means "another name for". enum, used in this context, means "manifest constant value of". Both descriptions can be applied to 2 (or any other literal) and reduce to the same effect, but when you start getting into non-literals, the meaning doesn't match:

int foo();

alias x = foo; // using x means to call foo
enum x = foo; // x is an enum int assigned the value of foo() evaluated at compile time

-Steve

Reply via email to