@property - take it behind the woodshed and shoot it?

kenji hara k.hara.pg at gmail.com
Thu Jan 24 17:37:51 PST 2013


2013/1/25 kenji hara <k.hara.pg at gmail.com>
>
>
> I have thought an additional idea.
> If we really want a feature to disable optional parentheses for normal
> functions, we can add @function attribute to the language spec.
>
> int foo();
> @property int bar();
> @function int baz();  // new!
>
> int x1 = foo();  // ok
> int x2 = foo;  // optional parentheses, allowed
> int y1 = bar();  // disallowed, calling int is meaningless
> int y2 = bar;  // ok
> int z1 = baz();  // ok
> int z2 = baz;  // *disallowed* by @function attribute
>

I think calling a function which does not annotated with @attribute without
parenthesis is legal, Even if a function has some side-effects and a name
looks like verb. Because native English grammar does not require
parentheses.

He runs().  // normal function call
He runs.    // optional parentheses

Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130125/c72d6fb7/attachment.html>


More information about the Digitalmars-d mailing list