@property - take it behind the woodshed and shoot it?

Adam D. Ruppe destructionator at gmail.com
Thu Jan 24 18:24:05 PST 2013


On Friday, 25 January 2013 at 02:03:27 UTC, Andrei Alexandrescu 
wrote:
> would Kenji's proposal float your boat?

Yeah, as described in more detail in this post:
http://forum.dlang.org/thread/kdqrnl$13ft$1@digitalmars.com?page=16

#1 preserves the status quo (important)
#2 is the key result I want from @property

There's some details I'd still argue, about address of (i say 
should be the return value), += etc on property (should become 
setter(getter() + rhs), unless there is no setter, in which case 
leave it how it is and let it operate on the return value 
naturally)

.... but I'm willing to compromise if we can get these two points:

#1:

Callable bar();
bar; // must work, returns the callable
bar(); // according to rule #1, this also just returns the 
callable
bar()(); // calls the callable

#2:

@property Callable foo();
foo; // just returns the callable
foo(); // must call the *Callable*, not just foo


And that's what Kenji is talking about, so yes, it is acceptable.


The rest is just gravy.

BTW I still say the sanest way to implement this is to rewrite 
foo into (foo()) ASAP. The parens will follow naturally from 
that, as will references and most everything else. The only hard 
part after that is to fix up setters, and perhaps clean existing 
mess out of dmd.

But I'm willing to defer to Walter or Kenji's expertise on 
actually making it happen.


More information about the Digitalmars-d mailing list