typeof(enum)

Ali Çehreli acehreli at yahoo.com
Fri Sep 7 16:04:24 PDT 2012


On 09/07/2012 03:55 PM, Minas wrote:
> import std.stdio;
>
> enum PI = 3.14;
>
> void main()
> {
> writeln(typeid(typeof(PI)));
> }
>
> It prints "double". Shouldn't it be immutable(double). I think it would
> make more sense, as it is a constant. Plus, it could be shared among
> threads.

immutable makes sense with variables (I know, it's an oxymoron. :)) PI 
in your code is just a manifest constant (i.e. it is just 3.14, nothing 
more).

In other words, its immutability comes from being an rvalue.

Ali


More information about the Digitalmars-d-learn mailing list