Mixin Expressions, can't evalutate string variable
Philippe Sigaud
philippe.sigaud at gmail.com
Fri Aug 6 13:22:34 PDT 2010
Andrej:
>
> It was just an exercise for fun but it's cool that things like this are
> possible in D. It would be nice if I could get the actual names of the
> parameters the function takes + the clear name of the function itself, that
> way I'd actually get back variables "ftc, fta, ftm" back)
There, found it again, while answering another thread:
int foo(int i, double d) { return 0;}
writeln(typeof(&foo).stringof); // "int function(int i, double d)" <-- Look
Ma, arguments names!
But it's a quirk of .stringof, I'm not sure it's a good idea to rely on it
too much.
from there, using compile-time search in a string, you can extract the
arguments (those are between ( and ) )
-> "int i, double d"
and from there, extracting i and d.
I don't what will happen for overloaded functions, methods names,
constructors, ...
Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100806/3e496c06/attachment.html>
More information about the Digitalmars-d
mailing list