Optional function invocation parentheses
Will Rubin
Will.Rubin at zippymail.info
Thu Sep 20 00:40:53 PDT 2012
I'm new to D. While poking around the site I stumbled across
Uniform Function Call Syntax. This lead me here:
http://www.reddit.com/r/programming/comments/vvpfy/uniform_function_call_syntax_in_d_gamedevnet/c58f8yy
I seem to remember reading that empty function invocation parens
were now optional so I tried it and it worked fine. But the
comments in the above thread indicate that there is something
special about removing them and it shouldn't be done so casually.
Are the following two "results" equivalent or is there something
special going on behind the scenes that makes result2 less
desirable?
import std.stdio;
import std.algorithm;
void main() {
auto result1 = [1, 2, 3, 4].filter!(a => a < 4)().reduce!((a,
b) => a + b)();
writeln("Result1: ", result1);
auto result2 = [1, 2, 3, 4].filter!(a => a < 4).reduce!((a, b)
=> a + b);
writeln("Result2: ", result2);
}
More information about the Digitalmars-d-learn
mailing list