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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jan 24 18:19:09 PST 2013


On 1/24/13 9:02 PM, Jonathan M Davis wrote:
> 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.

I agree parallels with natural language are tenuous.

Anyhow, here's a thought. It is becoming rather clear that one way or 
another that optional parens are here to stay. So no more need to argue 
over that - it's just there.

Once we consider this a given, the design space is much easier to 
navigate (which is what Kenji is doing).


Andrei




More information about the Digitalmars-d mailing list