Lazy evaluation of enum members

Gary Willoughby dev at nomad.so
Fri Sep 20 10:44:13 PDT 2013


On Friday, 20 September 2013 at 16:10:11 UTC, Walter Bright wrote:
> Enum member forward references now work:
>
> void main()
> {
>     enum E
>     {
>         A = B,
>         E = D + 7,
>         B = 3,
>         C,
>         D,
>     }
>
>     assert(E.A == 3);
>     assert(E.B == 3);
>     assert(E.C == 4);
>     assert(E.D == 5);
>     assert(E.E == 12);
>     assert(E.max == 12);
> }
>
> https://github.com/D-Programming-Language/dmd/pull/2568
>
> Once this is pulled, I intend to extend it so that enum members 
> for imports are not semantically evaluated at all unless they 
> are used. This is a first step to making all semantic 
> evaluation of imports lazy, which should give us a big boost in 
> compilation speed, as well as do a much better job at handling 
> forward references.
>
> I've been meaning to do this for some time, starting with enums 
> because they are the easiest.

Awesome!


More information about the Digitalmars-d mailing list