View mode: basic / threaded / horizontal-split · Log in · Help
February 27, 2013
optional parens everywhere except last position of function chain.
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.
February 27, 2013
Re: optional parens everywhere except last position of function chain.
On Wednesday, 27 February 2013 at 18:55:37 UTC, timotheecour 
wrote:
>
> Please let me know what you think.

spontaneously... I love it!
February 28, 2013
Re: optional parens everywhere except last position of function chain.
> spontaneously... I love it!

is there any other spontaneous feedback?
February 28, 2013
Re: optional parens everywhere except last position of function chain.
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.
March 01, 2013
Re: optional parens everywhere except last position of function chain.
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.
Top | Discussion index | About this forum | D home