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

Jonathan M Davis jmdavisProg at gmx.com
Thu Jan 24 18:02:23 PST 2013


On Friday, January 25, 2013 10:37:51 kenji hara wrote:
> 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

Honestly, I don't think that English grammar has anything to do with this. 
Code isn't English, even if the symbol names chosen are in English. A 
programming language's grammar should reflect what works best for having a 
language which is appropriately usable and maintainable. That doesn't 
necessarily have anything to do with the grammar of any natural language, 
especially when you consider how different programming language grammars are 
from those of natural languages.

- Jonathan M Davis


More information about the Digitalmars-d mailing list