www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - where is parameterNames?

reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
pragma(msg, __traits(parameterNames, Constructors[0]));

gives me

tok.d(19): Error: unrecognized trait parameterNames
Aug 13 2012
next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
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
Aug 13 2012
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
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.
Aug 13 2012
parent "bearophile" <bearophileHUGS lycos.com> writes:
Ellery Newcomer:

 I was thinking about adding keyword argument support to pyd 
 wrapped functions.
Maybe you have to process the JSON output? Bye, bearophile
Aug 14 2012
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
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
Aug 14 2012
next sibling parent reply "David Nadlinger" <see klickverbot.at> writes:
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
Aug 14 2012
parent Jacob Carlborg <doob me.com> writes:
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
Aug 14 2012
prev sibling parent reply "David Nadlinger" <see klickverbot.at> writes:
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
Aug 15 2012
next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
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?
Aug 15 2012
prev sibling parent Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
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?
Aug 19 2012