@property

Adam D. Ruppe destructionator at gmail.com
Sun Aug 5 08:59:12 PDT 2012


On Sunday, 5 August 2012 at 15:45:37 UTC, bearophile wrote:
> What about turning octal into a propety to fix this problem?

octal actually works because it isn't a function.

But in general, changing non-properties to properties just for 
syntax is backward anyway. Whether something is a property or not 
isn't a question of parenthesis. I think it was a mistake to 
conflate "property" with "parenthesis-less syntax" in the first 
place, since they aren't really the same thing.

A getX/setX pair in C++ is conceptually a property, but uses a 
different syntax. A method call in Ruby is still a method call, 
despite being able to write it without parens.

Something should be marked @property because it fits the 
conceptual definition, not because you want to leave parens out.


That's also why I don't like -property's implementation: it 
focuses purely on the syntax, without worrying about the concept. 
If you get the concept right, the syntax will fit on its own - 
for example, a property returning an int shouldn't be callable 
with () because calling an int like a function is nonsense 
regardless.

> All my large amount of D2 code gives no warning with -property. 
> Maybe you should fix your code.

Maybe you should pay my mortgage.


More information about the Digitalmars-d mailing list