www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - optional parens everywhere except last position of function chain.

reply "timotheecour" <thelastmammoth gmail.com> writes:
Here's yet another proposal regarding optional parens that makes 
a single simple rule to resolve ambiguities:

A symbol 'foo' that refers to a non- property-qualified function 
or function template is rewritten to foo() iff it is followed by 
a dot (".").

There's probably a better way to rephrase this in terms of AST, 
but in other words, parens are optional inside a function 
forwarding chain, but mandatory for the last element of the 
function chain.

When a,b,c are non-property functions:
a.b.c(); => a().b().c(); // c is called
a.b.c; // c function not called
c(); => // c is called
c; => // c not called
typeof(c) => function type
typeof(c()) => return type

[1,2].sort.map!cos.array.sort.reduce!max.writeln();
=>[1,2].sort().map!cos().array().sort().reduce!max().writeln();

Advantages:
No complex special cases, it is unambiguous for both compiler and 
user.

Please let me know what you think.
Feb 27 2013
parent reply "Tove" <tove fransson.se> writes:
On Wednesday, 27 February 2013 at 18:55:37 UTC, timotheecour 
wrote:
 Please let me know what you think.
spontaneously... I love it!
Feb 27 2013
parent reply "timotheecour" <thelastmammoth gmail.com> writes:
 spontaneously... I love it!
is there any other spontaneous feedback?
Feb 28 2013
next sibling parent FG <home fgda.pl> writes:
On 2013-02-28 23:00, timotheecour wrote:
 spontaneously... I love it!
is there any other spontaneous feedback?
Spontaneously... I hate it. :) I prefer optional parentheses everywhere.
Feb 28 2013
prev sibling parent "deadalnix" <deadalnix gmail.com> writes:
On Thursday, 28 February 2013 at 22:00:22 UTC, timotheecour wrote:
 spontaneously... I love it!
is there any other spontaneous feedback?
Love it as well.
Feb 28 2013