Is there a way to get the names of a function's parameters?
Jacob Carlborg
doob at me.com
Mon Jun 14 03:07:47 PDT 2010
On 2010-06-14 00:56, Adam Ruppe wrote:
> Given:
>
> void foo(int a, string b);
>
> You can use std.traits.ParameterTypeTuple to get (int, string).
>
> Is there any method, at all, to get ("a", "b") out of it? I can't find
> one, and am considering import("mysrc.d"); and finding it that way,
> but figured I'd ask first.
>
> The benefits of getting the names would be runtime function calls, or
> named arguments. Consider this:
>
> ParameterTuple!foo args;
>
> args.b = "hello";
>
> foo(args);
>
> That'd be kinda cool.
Here you go: http://tango.pastebin.com/M38jdhGd including calling using
named arguments.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list