Is there a way to get the names of a function's parameters?

Jacob Carlborg doob at me.com
Tue Jun 15 03:03:16 PDT 2010


On 2010-06-14 15:47, Simen kjaeraas wrote:
> Simen kjaeraas <simen.kjaras at gmail.com> wrote:
>
>> One needs to match parentheses from the last parentheses in the
>> typeof.stringof.
>
>
> string parameterNamesOf( alias fn )( ) {
> string fullName = typeof(&fn).stringof;
>
> int pos = fullName.lastIndexOf( ')' );
> int end = pos;
> int count = 0;
> do {
> if ( fullName[pos] == ')' ) {
> count++;
> } else if ( fullName[pos] == '(' ) {
> count--;
> }
> pos--;
> } while ( count > 0 );
>
> return fullName[pos+2..end];
> }
>

Thanks.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list