Make dur a property?
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Wed Jan 23 20:00:38 PST 2013
On Wed, 23 Jan 2013 22:59:38 +0100
"monarch_dodra" <monarchdodra at gmail.com> wrote:
>
> --------
> IMO: We should be able to keep the optional parenthesis for all
> functions (except maybe those that return delegates).
I'm not a fan of that as I think the need for special-casing of
functions returning delegates is not worth what I still don't see as a
benefit.
Side note: I know at least one person here likes this [ ;) ], but I
really hate code like:
foo.doStuff;
foo.makeFizzBar;
foo.updateBlorg;
Have to do a double-take every time. Just looks like a bunch of
no-ops, and sets off mental red flags every single time.
> Things that
> are marked as property, however, MUST respect two things:
> 1) properties should *NEVER* have parentheses.
Agreed
> 2) you should not be able to take the address of a property
> function.
Agreed
One could argue that you should be able to take the address of a
property, just like any other function, and to end up with a delegate.
But if you need to do that you can just use a lambda. It may be an
extra function call and indirection, but that's optimizable out, right?
That way you get to eat your delegate cake and still have no accedental
surprises arising from "&foo.bar" being an unexpected type.
> 3) The "a.prop = value" should call "a.prop(value)" IFF prop is
> declared property.
>
Agreed
I would also add:
4) Setters must be called like "a.prop = value", never "a.prop(value)"
5) Finally get rid of the damn -property switch (or maybe just make it
a no-op for build script backwards-compatibility, at least for a few
releases)
More information about the Digitalmars-d
mailing list