On 2011-03-05 16:49:30 -0500, dsimcha <dsim...@yahoo.com> said:

On 3/5/2011 4:42 PM, Michel Fortin wrote:
I've always been on the fence about this. I find it useful too, and I
like the visual effect of optional parenthesis. But returning anything
that is callable make things ambiguous to the reader and can even bring
bugs when it comes to generic programming; and ambiguity and bugs are
things I really don't want to see.

So? Make the semantics of @property one-way instead of two-way and make it a best practice to always use it in generic code. @property functions **can't** be called with (), but ()s are **optional** for stuff not marked @property.

There's still a small ambiguity with functions returning callable types. For instance, if you have a template defining a property of a parametrized type, forgetting to add @property to the getter could result in buggy behaviour with a callable type but work fine with everything else. Is making parenthesis optional worth making this kind of bug easier to slip by, I wonder.

That said, () being optional doesn't help you use setters with chaining. You'd have to not label your setters with @property for them to work with chaining, unless you want to play with a lot of nested parenthesis.

        (((Graph().title = abc).xTitle = def).yTitle = hij);

Wow, that looks almost like Objective-C!

This discussion should probably happen somewhere else than the announcement forum though.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to