1.0 ?? [templates and currying]
Walter Bright
newshound at digitalmars.com
Mon Nov 6 18:14:43 PST 2006
Tom S wrote:
> Walter Bright wrote:
>> BTW, I am considering changing the ==function and ==delegate is
>> expressions, which you use, to the following:
>>
>>
>> ==return gets the return type:
>>
>>> template Return(dg)
>>> {
>>> static if (is(dg R == return))
>>> alias R Return;
>>> else
>>> static assert(0, "argument has no return type");
>>> }
>>
>> ==function or ==delegate gets the parameter types as a tuple:
>>
>>> template Parameters(dg)
>>> {
>>> static if (is(dg P == function))
>>> alias P Parameters;
>>> else static if (is(dg P == delegate))
>>> alias P Parameters;
>>> else static if (is(dg P == P*))
>>> alias Parameters!(P) Parameters;
>>> else
>>> static assert(0, "argument has no parameters");
>>> }
>>
>> This will require some adjustment in your code. I didn't think anyone
>> was using that stuff. Will it be an issue for you? Or should I find
>> another way to do it?
>
> Whoa, That would be awesome ! I don't think anyone would mind such a
> change :)
> I'm certainly not the only one to use that code/feature. E.g. that link
> I gave you is from Kirk's Pyd, which contains modified versions of my
> code. It's also based on efforts from Daniel Keep. But I'm sure they
> will gladly welcome the enhancement you're proposing :)
I hate to tip over working code. I'll see if I can find another way.
> One question thought: will the 'P' tuple from your example be able to
> remember in/out/inout/lazy modifiers ?
I don't know. I'll have to work on that.
More information about the Digitalmars-d
mailing list