On Thursday, September 15, 2011 14:59:29 Don wrote: > On 08.09.2011 17:26, Christian Kamm wrote: > > Timon Gehr wrote: > >> I am strongly in favor of disallowing any cases where mixin > >> declarations > >> shadow declarations that were used to compute mixin declarations in a > >> scope that allows forward references. > >> > >> > >> Any thoughts on this? > > > > Order-of-static-evaluation problems are not limited to mixins: > > > > static if (!is(typeof(foo)) enum bar = 1; > > static if (!is(typeof(bar)) enum foo = 1; > > > > with the way dmd handles forward references, this can go either way > > depending on which static if gets evaluated first. D's wish that 'the > > order of declarations does not matter' is impossible to fulfill due to > > mixins and static if. > > > > They are special because they can alter the symbol table based on the > > contents of the symbol table. > > > > I think you could get away with defining that 'the order of declarations > > does not matter - except for static if and mixin which always get > > evaluated in lexical order'. I'm not sure how much work it'd be to make > > dmd behave that way. It probably wouldn't be worthwile. > > I prefer: The order of declarations NEVER matters, and the above code is > illegal. It's easy to implement.
The order matters for static if and version when you have else-if and/or else branches for them - it would be a problem if it didn't (especially for version, which is so dead-simple), but aside from that I agree that the order of declarations in non-local scope should never matter. - Jonathan M Davis
