On Wednesday, 13 April 2016 at 05:30:27 UTC, Vladimir Panteleev
wrote:
On Tuesday, 12 April 2016 at 13:44:07 UTC, Mithun Hunsur wrote:
Hi all,
I'm looking for the equivalent of `typeof(this)` in module
scope (so that it gets the current module). My use-case is
iterating over the members of the module - right now I'm doing
`mixin(iterateOverModule!(module.name.here));`
but in the interests of keeping the code simple to maintain,
I'd like to be able to get the current module automatically.
Is this possible? A cursory Google search didn't turn up
anything, and `this` has no meaning in module scope.
Have you tried __traits(parent, someTopLevelSymbol)?
Walking the __traits(parent) chain should get you to a module
either way, I think.
Yeah, that also works; you have to define a symbol (if you don't
have one you can already use) in order to get to it, so it's a
little wasteful. Still useful to know, though!