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

simendsjo simendsjo at gmail.com
Thu May 31 02:58:41 PDT 2012


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 ().


More information about the Digitalmars-d mailing list