Are there any default dmd optimizations

deadalnix deadalnix at gmail.com
Wed Feb 27 20:01:59 PST 2013


On Wednesday, 27 February 2013 at 23:34:42 UTC, Walter Bright 
wrote:
> 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.

Plus, this is really hard to ensure that everything is 
initialized properly without going eager with setting to init.


More information about the Digitalmars-d mailing list