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

Sandeep Datta datta.sandeep at gmail.com
Thu May 31 03:30:15 PDT 2012


On Thursday, 31 May 2012 at 09:58:42 UTC, simendsjo wrote:
> On Thu, 31 May 2012 11:36:47 +0200, Sandeep Datta 
> <datta.sandeep at gmail.com> wrote:
>
>> Hi,
>>
>> I was going through some sample code online and came across 
>> the following code fragment...
>>
>> 	listenHttp(settings, &handleRequest); //Where handleRequest 
>> is a function
>>
>> My question to you is (as the title says) is the address-of 
>> operator (&) really needed here? Wouldn't it be better to 
>> consider handleRequest to be a reference to the actual 
>> function? I think this will make the system consistent with 
>> the way variables work in D. IMO this will bring 
>> functions/delegates closer to being first class objects in D.
>>
>> What do you think?
>>
>
> It might be because of historical reasons.
> A long time ago, D allowed calling functions without (), so 
> what if handleRequest returns a function?
> Should the passed reference be handleRequest or handleRequest()?
> This issue is still valid for properties as they can be called 
> without ().

Thanks for the information! But I think we should use real 
properties when we need to do that and stop using functions as 
improvised properties. Please see my response to Dejan Lekic for 
my argument supporting this claim.


More information about the Digitalmars-d mailing list