On Tuesday, 30 July 2013 at 11:01:07 UTC, JS wrote:
On Tuesday, 30 July 2013 at 10:36:15 UTC, Dicebot wrote:
You can use scoped local imports and avoid necessity to track
global state.
Huh? If I follow you, this won't work. I'm generating code so
don't have the luxury to mess with the outer scope where the
code is going.
mixin(code fragment)
user code
mixin(code fragment)
user code
if both code fragments have the same import statement then
there is an error. The only way for them to be aware of that is
to have a global state(well, relative to the scope they are in).
Don't have imports generated in two different mixins in same
scope. Either move each mixin into own scope, or move import
generation code into separate mixin that get called once per
scope. (example of vibe.d using latter:
https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/http/rest.d#L245)