Andrei Alexandrescu wrote:
Christopher Wright wrote:
Andrei Alexandrescu wrote:
grauzone wrote:
For classes and structs, this is already possible:
typeof(this).stringof
Not outside of a member function. This is crippling my Visitor
implementation.
I use it in static constructors. If it doesn't work, well, that's news
to me.
I don't know about "typeof(this) property;", though. I never tried it.
Now we only need a way to get some kind of compile time object for
functions and modules (like the type for classes/structs). Then you
simply can use .stringof on them.
There's much more to reflection that we need to define.
Runtime as well as compile time.
Compile-time. Runtime follows and only needs a little glue.
That glue requires user intervention. Would you add "mixin(Reflect);" to
every class you wrote? But even that isn't sufficient -- you would have
to implement some interface indicating that this class has reflection
information, and pass objects around via that interface rather than
using Object.
There should be a way to suppress emitting complex reflection
information -- a command-line flag and a pragma. But I think it's a bit
much to ask users to mark every class they create in two different ways.
Andrei