Peter Alexander:
f(x) ---> x.f() is not progress in language design.
I used to think the same. But Haskell offers "." and $ to chain
functions and remove parentheses, F# has the |> pipe operator.
In D UCFS is almost equally useful to turn nesting of function
calls in a more readable chain. In functional-style code this
makes a lot of difference, turning:
foo(bar(copy(baz(a), spam(b))))
Into:
baz(a).copy(b.spam()).bar().foo()
When I see 3+ nested parentheses I find it hard to read the
expression. While a chain is easy to read.
In theory. IMO the amount of time you spend trying to please
the type system could have been better spent optimizing your
code manually.
No code I have ever written would benefit significantly from
these potential optimisations. For example, one optimisation is
that pure function calls could be hoisted out of loops. Great,
except that if that function call had any significant cost
whatsoever, I would have already done that optimisation myself.
I used to write lot of D1 code too, and I've seen that managing
D2 const-related issues slows down significantly my coding
compared to D1 coding, so undeniably they have a cost.
But in D the main purpose of "pure" is not as optimization tool,
but more as a tool to enforce a better coding style, that makes
code understanding (and testing simpler), and helps avoid some
bugs, coming from using variables from outer scopes.
Bye,
bearophile