[dmd-internals] Fixing forward ref bugs for good

Andrei Alexandrescu andrei at erdani.com
Thu Sep 15 08:51:28 PDT 2011


On 9/15/11 4:44 AM, Don Clugston wrote:
> I think there is a simple solution to 'static if'.
> Do const folding on every static if condition, giving a boolean result.
> Do NOT evaluate any static if bodies yet.
> This would have the same effect as if every 'static if' were evaluated
> simultaneously.
> (There's a little bit of complexity with is() expressions that create
> symbols, they need to be cached but not added to the scope yet).
>
> Possibly const-fold every string mixin as well; this would make them
> also act as if they were all evaluated simultaneously.
> I don't know what should be done about template mixins though. But
> they might not be much of a problem.
> When this is complete, add all declarations from each static if body,
> and from every mixin, into the scope.
> When they're all inserted, look for static ifs and mixins again.
> Repeat the process until none are left.

This sounds like a very robust solution to me. It also produces 
intuitive behavior.

Andrei


More information about the dmd-internals mailing list