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

Jonathan M Davis jmdavisProg at gmx.com
Thu Jan 24 20:48:47 PST 2013


On Friday, January 25, 2013 13:47:31 kenji hara wrote:
> 2013/1/25 Jonathan M Davis <jmdavisProg at gmx.com>
> 
> > And actually, something far more important than any of those reasons is
> > the
> > issue of setters. We've focused most of this discussion on optional parens
> > and
> > the situation with getter properties, but setter properties and their
> > issues
> > are also important. Would you want code like this to compile?
> > 
> > range.popFront = 17;
> > container.linearRemove = range;
> > path.baseName = ".xyz";
> > str.icmp = "hello";
> > enforce(a == b) = "msg";
> > arr.sameHead = arr2;
> > 
> > With @property, we can restrict the functions which can be used with the
> > setter syntax to functions where that makes sense. Without it, all kinds
> > of
> > ridiculous code like the code above would be allowed.
> > 
> > Allowing optional parens is one thing, but conflating that with properties
> > is
> > something else entirely. Property functions are not just functions which
> > are
> > called without parens, and we shouldn't act like they are.
> 
> I have explained an additional rule in #1a.

I know, and I agree with it. But Andrei is pushing for removing @property 
entirely and looking for arguments to keep it. And IMHO, the issue of how 
setters are handled is an extremely good reason to keep @property.

- Jonathan M Davis


More information about the Digitalmars-d mailing list