On 07/19/2012 08:03 AM, Petr Janda wrote:
>> It's just syntax. Eliminating syntax noise is fine. Code should look
>> like what it does.
>
> Not if "eliminating noise" equals to making things harder to understand.
>
> When you say (int x) { return x; } it's clear about what it is, a
> _function_ without name.

Others beat me to it but the anonymous function can be written more completely as

  function string(int x) { return x.to!string(); }

(Or 'delegate' depending on the situation.)

Allow me to add a take(..., 2) to the entire expression, which is to me the strongest reason why UFCS can be great:

writeln(take(map!(function string(int x) { return x.to!string(); })(uniq(sort([5, 3, 5, 6, 8]))), 2));

The problem is, the 2 is related to take() but they are too far apart above. UFCS puts them together:

  a_long_expression.take(2)

I don't like UFCS everywhere but it is very helpful in many cases.

Ali

Reply via email to