Alias Vs. Enum?
Stefan Koch
uplink.coder at googlemail.com
Sun Jan 7 03:52:53 UTC 2018
On Saturday, 6 January 2018 at 21:33:46 UTC, Rubn wrote:
> Is there a reason for the differences between Enum and Alias?
> For the most part enums are only used for things that have a
> value, but alias is used more for types. But with templates you
> can get around this and you basically get the funcitonality of
> Enum for alias. Oddly enough from the template parameter being
> "alias".
>
>
> template valueOf(alias v)
> {
>
> }
>
> alias aa = AliasSeq!(10 == 10);
> enum ee = 10 == 10;
>
> alias err = 10 == 10; // error
>
> What are the actually differences here with aa and ee?
The compiler can only alias to symbols and not to values.
therefore enum was chosen for manifest constants.
That alias can bind to values in template-parameters is useful
but not exactly consistent :)
More information about the Digitalmars-d
mailing list