delegate with optional parameters

Inquie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 2 15:24:23 PDT 2017


On Sunday, 2 April 2017 at 21:47:55 UTC, Basile B. wrote:
> On Sunday, 2 April 2017 at 20:48:09 UTC, Inquie wrote:
>> On Sunday, 2 April 2017 at 20:02:56 UTC, Basile B. wrote:
>>> On Sunday, 2 April 2017 at 19:24:14 UTC, Inquie wrote:
>>>> is it possible to create a delegate that takes an optional 
>>>> number of parameters and/or return type?
>>>>
>>>> T delegate(S...)(S) special_delegate;
>>>>
>>>> I guess this is impossible?
>>>
>>> alias Dg(Return, Params...) = Return delegate(Params);
>>>
>>> Dg!(int,float, string) myDg;
>>
>> What I mean is that I want to be able to overload delegates 
>> like one can do with normal members.
>
> Show a usage, someone certainly propose a pattern that does the 
> job.

int delegate() f;
void delegate(int) f;

These are effectively overload methods, but my guess is that D 
won't support it like overloads.
e.g.,

int f();
void f(int);



More information about the Digitalmars-d-learn mailing list