Pelle Månsson wrote:
On 01/29/2010 06:19 PM, Andrei Alexandrescu wrote:
Ary Borenszweig wrote:
Andrei Alexandrescu wrote:
Steven Schveighoffer wrote:
On Fri, 29 Jan 2010 11:21:28 -0500, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:

How is f.byLine clearer and less ambiguous than f.byLine()? Or vice
versa for that matter?

Note that properties can be named things other than byLine.

-Steve

What I meant to say is that in the @property landscape the following
two conventions become suddenly attractive:

* Do not use @property at all

* Use @property for all nullary functions

And they're bound to save a lot of time to everyone involved.

The first post of this thread was about not invoking a function when
you don't want it to be invoked. bearophile was doing:

auto dg = int function() { ... };
return dg;

but he wanted to return a reference to dg, not the result of invoking
it. One way to prevent that is to never invoke functions unless they
are marked with @property. Or maybe functions defined like that
(closures, whatever) should always require () to be invoked.

If that doesn't sound reasonable, see this:

auto dg1 = int function() { ... };
auto dg2 = dg1;

I'd expect dg2's type to be dg1's type.

Let's just think a solution to this problem first. :-)

Correct. Just that I fear that it's a bit late for this all. It is
disheartening enough that Walter got convinced by the past discussion
and introduced @property without much design - after a FAILED vote no
less. I strongly believe a better solution is available, but everyone
wanted the feature so the feature just got born.

FWIW, my take for issues like the above: if a function returns a
function or a delegate, it can't avail itself of automatic invocation of
"()". That takes care of a corner case and keeps the mainstream case in
good shape.

I am not sure of a good solution for problems like

writeln = 2;


Andrei

How about @property? When you add a @property to a function it can be called as an assignment. @property does not touch the calling of no-argument functions.

Are there any problems with that?

Such a "@property is just for the writing" design will leave @property adepts very unhappy, I think. Even I admit that such a rule will be very inconsistent, albeit workable.

Andrei

Reply via email to