typeof(enum)

Timon Gehr timon.gehr at gmx.ch
Fri Sep 7 20:19:47 PDT 2012


Accidentally replied to your private email first.

On 09/08/2012 12:55 AM, Minas wrote:
> import std.stdio;
>
> enum PI = 3.14;
>
> void main()
> {
>      writeln(typeid(typeof(PI)));
> }
>
> It prints "double". Shouldn't it be immutable(double).

No.

auto x = PI;
x++;

> I think it would  make more sense, as it is a constant.

It never makes sense to have mutable values, but their type may still 
allow mutation of variables of that type.

> Plus, it could be shared among threads.

The symbol PI does not exist at runtime.


More information about the Digitalmars-d-learn mailing list