[Issue 1732] Mixin can not be instantiated

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 16 08:14:38 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1732





------- Comment #3 from matti.niemenmaa+dbugzilla at iki.fi  2007-12-16 10:14 -------
The difference is that one imports a declaration while the other imports a
statement. The init() with a function could be mixed in at global scope or
class scope, whereas the "a = 5" one only works at function scope.

I see where you're coming from, though: some sort of implicitness here might be
handy. For instance, if a template contains statements, it is allowed only as a
mixin at function scope. That is:

template T() { statements }
void foo() { mixin T; }

Could be equivalent to:

template T() { void __unique_internal_name() { statements } }
void foo() { mixin T; __unique_internal_name(); }

And you get inlining for free.


-- 



More information about the Digitalmars-d-bugs mailing list