modulename
Jonathan M Davis
jmdavisProg at gmx.com
Tue Sep 4 14:00:55 PDT 2012
On Tuesday, September 04, 2012 22:40:19 Andrej Mitrovic wrote:
> On 9/4/12, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > But it looks like we now have std.traits.moduleName, so presumably that
> > will do the trick.
>
> How will that do the trick if you don't have the reference to the
> invoking module?
Clearly, I didn't read the OP clearly enough.
Unless you can get code to be generated in the calling scope (e.g. with
mixins), then the _only_ access that you have to anything in the calling scope
is with __FILE__ and __LINE__. And they only work that way because they're
treated as special cases (they _don't_ work that way in C/C++). Pretty much by
definition, anything that you type is in the scope that you type it.
You _might_ be able to get it to work by having the caller explicitly pass
something via an alias template parameter, but if you wanted something
explicit, you could have the caller just pass a string with the module's name.
I pretty darn sure that there's no way to get the compiler to tell you what
you're looking for without the caller doing something.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list