On Friday, 3 May 2019 at 17:55:19 UTC, faissaloo wrote:
On Friday, 3 May 2019 at 17:51:39 UTC, Adam D. Ruppe wrote:
On Friday, 3 May 2019 at 17:48:50 UTC, faissaloo wrote:
How can I get a mixin to implicitly include the symbols from
its surrounding context? Is this possible?
What's your big picture goal? Do you have sample code you have
tried so far?
Also, are you talking mixin("string") or mixin template? They
work differently with symbols too.
My sample code is too big to be useful. The use of my mixin
looks like:
mixin(defState!("XEvent value;"));
But it tells me it can't find the symbol XEvent despite me
having used it elsewhere.
It's because XEvent is not visible in the scope, you need to
import the module it is contained in. mixin templates are used in
the call scope, not the defining scope.
You have some misunderstanding of D meta programming but you h
ave not given enough info to diagnose the problem.
You look to be using a string that represents a code string that
will be later mixed in(as a string mixin) but you are also using
a template mixin.
But most likely you simply need to add an "import ..." somewhere
to get XEvent in the scope. Sometimes this is a little tricky
because you want to generalize it so you have to do some weird
stuff and use mixin("import "~moduleName!T~";");