Is the address-of operator (&) really needed?

Dejan Lekic dejan.lekic at gmail.com
Thu May 31 05:25:28 PDT 2012


On Thu, 31 May 2012 12:25:20 +0200, Sandeep Datta wrote:

>>   //fptr = handleRequest; // will not work, because it is
>> "understdood"
>> as:
>>                           // fptr = handleRequest();
>>
>>
> But do we really need this feature? Typing () does not seem to be too
> much work besides we can use properties if we really need to drop the
> brackets. And given the fact that properties have well understood use
> cases (see
> http://msdn.microsoft.com/en-us/library/bzwdh01d
(VS.71).aspx#cpconpropertyusageguidelinesanchor1)
> I am not sure using functions as properties is such a good idea.
> 
>>   fptr = &handleRequest;  // This will work if we have only one
>> handleRequest();
>>                           // If you uncomment the first one,
>> you are in
>> trouble
> 
> Can't we use auto-inferencing here to select the right method since fptr
> has the required type information?

Nope, i specifically made this example because D makes no difference 
between two or more functions with different return types.


-- 
Dejan Lekic
  mailto:dejan.lekic(a)gmail.com
  http://dejan.lekic.org 


More information about the Digitalmars-d mailing list