Are there any default dmd optimizations

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Feb 28 11:54:28 PST 2013


On 2/28/13, Timon Gehr <timon.gehr at gmx.ch> wrote:
> It's really easy. DMD can be convinced to do a sufficient conservative
> analysis even now, but the behaviour is undocumented and seems
> unintentional.
>
>
>      void main() {
>          void foo()() { bar(); }
>          void bar()() { i = 3; }
>          int i;
>          foo();
>      }

You can even make them non-templates if they're part of a mixin template.

mixin template T()
{
    void foo() { bar(); }
    void bar() { i = 3; }
    int i;
}

void main()
{
    mixin T!();
    foo();
}


More information about the Digitalmars-d mailing list