Why is std.algorithm so complicated to use?

Timon Gehr timon.gehr at gmx.ch
Mon Jul 9 13:51:29 PDT 2012


On 07/09/2012 10:23 PM, Ali Çehreli wrote:
> On 07/09/2012 01:16 PM, Andrei Alexandrescu wrote:
>  > On 7/9/12 4:09 PM, Jacob Carlborg wrote:
>
>  >> auto str = ["foo", "bar"].map!(x => x);
>  >> auto f = str.sort();
>  >>
>  >> Results in:
>  >>
>  >> http://pastebin.com/BeePWQk9
>  >
>  > The first error message is at clear as it goes:
>  >
>  > Error: r[i2] is not an lvalue
>
> And a quick fix is to make an array first:
>
> auto str = ["foo", "bar"].map!(x => x)().array();
>
> Also note the added () for map, which is needed when compiled with
> -property.
>
> Ali
>

-property should be killed.

I mean, we can have either

map!(x => x)().array()

or

map!(x => x).array

It's blatantly obvious which one we want, especially when there are
more than two chained/nested calls. -property is good only for bracket
spam.

We need to implement @property properly, that is, @property function
pairs behave like fields and other functions can be called with the
parentheses left off. IIRC that is how it was designed initially.


More information about the Digitalmars-d mailing list