DIP23 draft: Fixing properties redux

kenji hara k.hara.pg at gmail.com
Sun Feb 3 05:33:55 PST 2013


2013/2/3 FG <home at fgda.pl>

> On 2013-02-03 09:16, Andrei Alexandrescu wrote:
>
>> Walter and I have had a discussion on how to finalize properties.
>>
>
> Very reasonable in the majority of the proposal.
> I can't, however, get my head around 2-arg property functions:
>
>     int a_;
>     @property void a(int v, bool rev=false) { a_ = rev ? -v : v; }
>     a = 10;       // fine
>     10.a = true;  // this feels backwards, true is just an extra flag
>
> The boolean flag is optional and making it the rhs of the assignment
> suggests it is the value which will be set. On the other hand switching
> argument positions, resulting in true.a = 10 also feels very strange.
>
> I'd say: allow only 0 or 1 argument in properties.
> If you need more arguments, write a normal function for it.
>

Two arguments @property function would be declared only in module level,
and just be called with UFCS.
I think that functions annotated with @property must not have default
parameters. As you show, it would introduce not little ambiguity.

Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130203/f5c0ed27/attachment.html>


More information about the Digitalmars-d mailing list