On 06/24/2010 11:11 AM, Steve Schveighoffer wrote:
And as far as "design by newsgroup" I think almost all the new
features were vetted on the newsgroup at one point, including inout.
It's unfair to simply point to ones you disagree with as evidence of
failure ;)

I was referring to those that have arguably shown themselves to be failures.

In defense of @property, I think we all agree we needed something to
distinguish setters from single-arg functions.  I think with a
reasonable rule, we can allow calling no-arg functions without parens
(via a proposal I made earlier that as long as the function returns
void, it should be allowed).

Fine, though that leaves writeln = 5; on the table.

All that's left is actual property
getters.  I can't say enough that @property in those cases has
nothing to do with functionality and everything to do with human
interpretation.  Like it or not, the use of parentheses is an
extension of the function name, whose semantic meaning of course is
unenforceable.  But just allowing the user to decide whether
something is a property or a function leaves the interpretation up to
the user, taking all the power away from the author who wrote the
function.  @property is a clarification tool, and by necessity, is
implemented via convention rather than compiler enforcement.

I've heard this argument before. I acknowledge there is a need to address unpleasant corner cases such as functions that return functions or delegates. What I'm saying is that the feature as designed hurts most for the benefit of a couple tiny corner cases. I've seen that several times in several language before. It's called bad design.

What I'm seeing in the field after faithfully using @property for a while fits my worst predictions:

1. Code is sprinkled with @property so there's more syntactic noise to introduce and to deal with;

2. Whenever I define some function I need to make an arbitrary decision whether that will be a @property or not. Reasonable people could ask me why I chose whichever way I chose. (Most recent example: save() for forward ranges.) Arbitrary decisions are bad.

@property is badly designed, no two ways about it. I now regret I didn't lobby more against it. I have a similar regret about lazy.


Andrei
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to