optional parens everywhere except last position of function chain.
timotheecour
thelastmammoth at gmail.com
Wed Feb 27 10:55:35 PST 2013
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- at 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.
More information about the Digitalmars-d
mailing list