DIP26: properties defined

Jonathan M Davis jmdavisProg at gmx.com
Sat Feb 9 16:44:53 PST 2013


On Saturday, February 09, 2013 14:56:56 Andrei Alexandrescu wrote:
> On 2/9/13 2:21 PM, Jonathan M Davis wrote:
> > Getting rid of @property will mean allowing stupid stuff like
> > 
> > range.popFrontN = 5;
> 
> No. This again conflates getters with the setter syntax.

How? If you don't have explicit properties, then _any_ function which has the 
appropriate set of parameters can be used as a property function, and there 
are many functions (both free functions and member functions) which have that 
set of parameters but clearly aren't meant to be properties. popFrontN is just 
one of them. The only reason that this isn't a problem in DIP23 is the fact 
that it makes it so that the only way that you get the setter syntax is to use 
@property.

Sure, you could decide that @property only applied to setters  and let getters 
only be done via parenless functon calls, but you'd still need explicit 
properties for setters to avoid problems like range.popFrontN = 5;. And if you 
get rid of explicit getters, then you're still losing when it comes to stuff 
like delegates and the ability to swap out variables with property functions 
like you're supposed to be able to do with properties.

- Jonathan M Davis


More information about the Digitalmars-d mailing list