Thread overview
where is parameterNames?
Aug 14, 2012
Ellery Newcomer
Aug 14, 2012
Jonathan M Davis
Aug 14, 2012
Ellery Newcomer
Aug 14, 2012
bearophile
Aug 14, 2012
Jacob Carlborg
Aug 14, 2012
David Nadlinger
Aug 14, 2012
Jacob Carlborg
Aug 15, 2012
David Nadlinger
Aug 15, 2012
Philippe Sigaud
Aug 20, 2012
Ellery Newcomer
August 14, 2012
pragma(msg, __traits(parameterNames, Constructors[0]));

gives me

tok.d(19): Error: unrecognized trait parameterNames
August 14, 2012
On Monday, August 13, 2012 21:40:48 Ellery Newcomer wrote:
> pragma(msg, __traits(parameterNames, Constructors[0]));
> 
> gives me
> 
> tok.d(19): Error: unrecognized trait parameterNames

Parameter names aren't part of a function's API. Why would you need them?

- Jonathan M Davis
August 14, 2012
On 08/13/2012 09:49 PM, Jonathan M Davis wrote:
> On Monday, August 13, 2012 21:40:48 Ellery Newcomer wrote:
>> pragma(msg, __traits(parameterNames, Constructors[0]));
>>
>> gives me
>>
>> tok.d(19): Error: unrecognized trait parameterNames
>
> Parameter names aren't part of a function's API. Why would you need them?
>
> - Jonathan M Davis
>

I was thinking about adding keyword argument support to pyd wrapped functions.
August 14, 2012
Ellery Newcomer:

> I was thinking about adding keyword argument support to pyd wrapped functions.

Maybe you have to process the JSON output?

Bye,
bearophile
August 14, 2012
On 2012-08-14 06:40, Ellery Newcomer wrote:
> pragma(msg, __traits(parameterNames, Constructors[0]));
>
> gives me
>
> tok.d(19): Error: unrecognized trait parameterNames

I don't know if this works any better:

https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L29

It's a simple implementation.

I also have a function which also you to call another function using named arguments:

https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L135

Neither of these two support delegate parameters.

-- 
/Jacob Carlborg
August 14, 2012
On Tuesday, 14 August 2012 at 16:06:33 UTC, Jacob Carlborg wrote:
> I don't know if this works any better:
>
> https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L29
>
> It's a simple implementation.

Nice hack, but when using this on functions you don't control, be aware that parameter names are officially not considered part of the API (as it became clear in the named parameter-related discussions). This implies that e.g.  the parameter names of Phobos functions might change at any time.

David
August 14, 2012
On 2012-08-14 20:29, David Nadlinger wrote:

> Nice hack, but when using this on functions you don't control, be aware
> that parameter names are officially not considered part of the API (as
> it became clear in the named parameter-related discussions). This
> implies that e.g. the parameter names of Phobos functions might change
> at any time.

Of course, this was more a "just because it's possible".

-- 
/Jacob Carlborg
August 15, 2012
On Tuesday, 14 August 2012 at 16:06:33 UTC, Jacob Carlborg wrote:
> https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L29

Related: https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L510

David
August 15, 2012
On Wed, Aug 15, 2012 at 6:46 PM, David Nadlinger <see@klickverbot.at> wrote:
> On Tuesday, 14 August 2012 at 16:06:33 UTC, Jacob Carlborg wrote:
>>
>>
>> https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L29
>
>
> Related: https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L510

Hmm:

static if (is(typeof(func[0]) PT == __parameters))

__parameters is a new feature in is()' treasure vault, right?

Testing it, it seems to return the parameter tuple of a function. That's cool. However, that'd be cooler if it was documented somewhere. Was that in 2.060 changelog?
August 20, 2012
On 08/15/2012 09:46 AM, David Nadlinger wrote:
>
> Related:
> https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L510
>
>
> David

That should work nicely.

Why does it not show up on dlang.org?