On Friday, 3 May 2019 at 17:55:19 UTC, faissaloo wrote:
But it tells me it can't find the symbol XEvent despite me
having used it elsewhere.
Where is elsewhere? Is it in the same module as the mixin?
mixin strings like that are similar to pasting the generated code
into the site of the mixin() thing, into that module, which means
anything the string references needs to be visible here too.
I'm assuming `defState!(x)` returns a string based on x. So when
you do
mixin(defState!("XEvent value;"));
defState returns something like
"XEvent value; some other stuff;"
If you take away the quotes and just write that instead of mixin,
you would get the same effect. XEvent needs to be in scope at
*that* point.
If you are writing
import module.with.XEvent;
mixin(defState!("XEvent value;"));
And are still getting an error, it must be because defState is
also doing something with it. I would suggest redesigning it then
to take the type separately. Maybe
template defState(T, string name) { ... }
and you call it
mixin(defState!(XEvent, "value"));
because now XEvent itself is only seen outside the defState call,
and inside the thing, it can just use T.
but this all depends on the details of what you're doing.