Calling Syntax (no, not UFCS)

sigod via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 3 15:45:30 PDT 2015


On Monday, 3 August 2015 at 22:42:15 UTC, SirNickolas wrote:
> Hello! I'm new in D and it is amazing!
>
> Can you tell me please if it is discouraged or deprecated to 
> call a function by just putting its name, without brackets? 
> It's quite unusual for me (used C++ and Python before), but I 
> can see this practice even in the official Phobos documentation:
>
> ```
> foreach (result; [ 1, 2, 3, 4 ].map!("a + a", "a * a"))
>     ...
> ```
>
> The code `.map!("a + a", "a * a")()` also compiles and works as 
> expected, of course.

http://dlang.org/function.html#optional-parenthesis

Also note http://dlang.org/function.html#property-functions


More information about the Digitalmars-d-learn mailing list