@property - take it behind the woodshed and shoot it?
Steven Schveighoffer
schveiguy at yahoo.com
Mon Jan 28 09:07:39 PST 2013
On Mon, 28 Jan 2013 11:31:33 -0500, Timon Gehr <timon.gehr at gmx.ch> wrote:
> On 01/28/2013 06:22 AM, Steven Schveighoffer wrote:
>> ...
>>
>> I would be satisfied with Kenji's implementation. As I understand it:
>>
>> @property on a getter would mean implicit calling of the function.
>> @property on a setter would mean calling x = y as x(y).
>> @property functions could not be called like normal functions.
>> Parentheses are optional on normal no-arg functions when used as
>> getters.
>> Normal single arg or variadic functions are NOT ALLOWED to be used as
>> setters.
>> ...
>
> This proposal unfortunately does not work too well because of UFCS.
As many have stated in the past, UFCS getter properties can annotate their
"this" argument:
@property void by5(this int x) { return x * 5;}
by5 = 1; // error
Another possibility is to only define @property for setters. This is
something I've come to realize that if we are simply going to allow
omittable parens on getters, there is no functional value to @property on
them except for the rare case of a delegate property. That was always one
of those things where I think too much emphasis was on that as a reason
for @property existence, it's very rare.
-Steve
More information about the Digitalmars-d
mailing list