New Traits
John Maschmeyer
jmaschme at gmail.com
Tue May 15 14:09:02 PDT 2012
On Tuesday, 15 May 2012 at 17:18:57 UTC, Philippe Sigaud wrote:
> Can you give us a simple example of what codeof produces? How
> does it
> deal with functions overloads?
import std.stdio;
void bar() {
writeln("testing");
}
struct Foo {
public:
int x;
int y;
}
void main() {
writeln("*************");
writeln(__traits(codeof, bar));
writeln("*************");
writeln(__traits(codeof, Foo));
writeln("*************");
}
This prints:
*************
void bar()
{
writeln("testing");
}
*************
struct Foo
{
public
{
int x;
int y;
}
}
*************
I'm not sure how well this works with overloads. If you just use
the symbol name, it works like other traits and returns the
source code for the first match. I tried using the getOverloads
trait and some alias magic, but all I've been able to do so far
is get the prototype for overloads. I'm guessing it has
something to do with using an alias instead of the actual symbol.
I think we need a better way to reference an overloaded symbol.
More information about the Digitalmars-d
mailing list