@property (again)

John Colvin john.loughran.colvin at gmail.com
Thu Nov 21 06:12:57 PST 2013


On Thursday, 21 November 2013 at 13:04:21 UTC, John Colvin wrote:
> On Thursday, 21 November 2013 at 03:14:30 UTC, Manu wrote:
>> It would be nice to have a commitment on @property.
>> Currently, () is optional on all functions, and @property 
>> means nothing.
>> I personally think () should not be optional, and @property 
>> should require
>> that () is not present (ie, @property has meaning).
>>
>> This is annoying:
>>  alias F = function();
>>
>>  @property F myProperty() { return f; }
>>
>>  Then we have this confusing situation:
>>    myProperty(); // am I calling the property, or am I calling 
>> the
>> function the property returns?
>
> The latter. Property should be enforced properly.
>
>> This comes up all the time, and it really grates my nerves.
>> Suggest; remove @property, or make it do what it's supposed to 
>> do.
>
>
> If you combine:
>
> 1) enforced property syntax, no parens allowed
>
> 2) & always applies to a parenthesis-less function, not it's 
> result
>
> 3) properties decay to normal functions when they have their 
> address taken
>
> 4) For template params: pass function symbol if possible, 
> otherwise evaluate and pass the result.
>
> then we have a solved problem, while allowing people to keep 
> their nice pretty ()-less UFCS chains, no?

I forgot to add:

5) parenthesis are enforced for all calls on all callables other 
than functions, including function pointers and delegates.


More information about the Digitalmars-d mailing list