Are there any default dmd optimizations

Walter Bright newshound2 at digitalmars.com
Wed Feb 27 15:34:29 PST 2013


On 2/27/2013 2:55 PM, Nick Sabalausky wrote:
> I like that, but "run arbitrary code at top level" may be a bit of a
> problem because it conflicts with allowing forward references.
>
> Ie, for example:
>
>      void foo() { bar(); }
>      void bar() { i = 3; }
>      int i;
>
> vs:
>
>      void main() {
>          void foo() { bar(); }
>          void bar() { i = 3; }
>          int i;
>      }
>
>
> The first one works, but the second doesn't. And my understanding is
> that the second one not working is a deliberate thing related to
> not being in a declaration-only context.

It's a little more than that. People have a natural view of function bodies as 
executing top down. Functions also tend to be simple enough that this makes 
sense. People have a natural view outside functions as everything happening in 
parallel.


More information about the Digitalmars-d mailing list