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

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Thu May 31 04:18:15 PDT 2012


"Sandeep Datta" <datta.sandeep at gmail.com> wrote in message 
news:voifmkyfwlslfpgipvlj at forum.dlang.org...
>>   //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.
>

This has been a *HUGE* source of debate. It's D's own little "tabs vs 
spaces" war.

Ultimately, the () is going to be required (unless the function is marked 
@property, in which case it'll be required that you *don't* use the parens). 
And as has been said before, it already works this way if you give 
the -property switch to DMD (and this behavior is planned to become the 
default...someday). But the only reason any of this is happening at all is 
because of a specific ambiguity that was discovered with the old "empty 
parens are optional" approach.




More information about the Digitalmars-d mailing list