Function pointers/delegates default args were stealth removed?

Carl Sturtivant sturtivant at gmail.com
Mon Aug 27 03:53:55 PDT 2012


On Monday, 27 August 2012 at 08:39:01 UTC, Manu wrote:
> On 27 August 2012 11:12, Jonathan M Davis <jmdavisProg at gmx.com> 
> wrote:
>
>>
>> and it makes no sense to use them with function pointers or 
>> function
>> literals.
>>
>
> If that were true, we wouldn't be having this discussion.

I think that we (at a minimum me and my alter ego) would find it 
helpful to acknowledge something along the following lines (in no 
particular order).

1. There is call for a default argument mechanism when calling 
function or delegate pointers. [Those who've used these 
extensively know they want them! Now we think about it, we want 
them too.]

2. The existing default argument mechanism which is to simply pad 
the call at compile time with the defaults read from the function 
definition is ill suited to function pointer calls. [Those who 
want sane compiler machinery know this.]

3. It's helpful to overtly acknowledge that function calling and 
function pointer calling are quite different. [They are already 
different in D because overloading is applied statically, just as 
default arguments have now become something only applied 
statically. A function pointer is to one function and overloading 
therefore doesn't exist.]

4. Function pointer calls being dynamical could perhaps have a 
dynamical mechanism to assign default arguments at run time, so 
as to go along with notions 1,2,3 above. [That way the function 
decides which arguments have been defaulted and assigns their 
default values at runtime, so the language merely needs a 
mechanism for the function body when run to find out which 
parameters it needs to assign defaults to i.e. how many arguments 
have actually been provided when the function pointer was called.]

---hence my earlier proposal.

I'm feeling lonely ---please at least shoot it down!





More information about the Digitalmars-d mailing list