1.0 ?? [templates and currying]

Walter Bright newshound at digitalmars.com
Mon Nov 6 18:53:50 PST 2006


Daniel Keep wrote:
> Walter Bright wrote:
>> I hate to tip over working code. I'll see if I can find another way.
> 
> To derive a function's return type, number of arguments, type of
> arguments, I had to write an external Python script that spat out a huge
> ugly-as-hell D source file with support for functions of N arguments.

I'm writing an std.traits module, which will abstract away that stuff. 
So, if you're willing to rewrite using std.traits.Returns and std.traits 
.Parameters, you'll be immunized against changes in the future.

Also, to get number of parameters for function foo:

	Parameters!(foo).length

will do it. First parameter type is:

	Parameters!(foo)[0]

Rest of the parameter types are:

	Parameters!(foo)[1 .. length]

Etc.



More information about the Digitalmars-d mailing list