What's left for 1.0?

Bill Baxter dnewsgroup at billbaxter.com
Tue Nov 28 19:17:55 PST 2006


Kirk McDonald wrote:
> Bill Baxter wrote:
>> Kirk McDonald wrote:
>>> In writing Pyd, I've come to the conclusion that if you have a 
>>> template that accepts an arbitrary function as an alias parameter 
>>> (and then does anything involving the type of that function), you 
>>> should always have a second parameter representing the type of the 
>>> function. (And you can easily make this second parameter have a 
>>> default value of typeof(&fn).) In this way the user can be sure the 
>>> template is getting the proper overload of the function.
>>
>> If you had some extra condition like "I want to match the version with 
>> the most arguments" can you think of some way to make that work with 
>> the current D?
>>
>> --bb
> 
> No, because there is no way to get another overload of a function beyond 
> the first without knowing the type of the overload.
> 

Hmm, I was hoping maybe there's a way to use a series of templates like

     void set_function(Ret,A1,A2,A3)(Ret delegate(A1,A2,A3) dg) { ... }
     void set_function(Ret,A1,A2)(Ret delegate(A1,A2) dg) { ... }
     void set_function(Ret,A1)(Ret delegate(A1) dg) { ... }
     void set_function(Ret)(Ret delegate() dg) { ... }

where ifti would prefer the one with more arguments to one with fewer.
Of course if that were the solution it would take us right back into the 
bad old days before TypeTuples.

--bb



More information about the Digitalmars-d mailing list