Just where has this language gone wrong?

David d at dav1d.de
Thu Jul 19 07:25:35 PDT 2012


Am 19.07.2012 16:21, schrieb Petr Janda:
> Hi,
>
> I'm an occasional lurker on the D forums just to see where the language
> is going,but I'm a little puzzled. In another thread I found this code
>
> auto r = [5, 3, 5, 6, 8].sort.uniq.map!(x => x.to!string);
>
> I don't understand whats going on here. Int array is getting sorted,
> then Uniqued, then what? What type is x? What kind of operator is =>,
> why is x.to!string allowed template specialization should say
> x.to!(string), which leads me to think that there are multiple syntaxes
> for things(why I hate dynamic languages, love compiled)
>
> On another note, (copied from wikipedia)
>
> foreach(item; set) {
>    // do something to item
> }
>
> what's with the lax syntax being allowed? Shouldn't it be at least
> specified "auto item"?
>
> I'm sorry I don't mean to be a criticizer, but it seems to me that D is
> trying to be a dynamic-like compiled language way too hard.
>

=> → New Lambda Syntax
.sort.uniq.map(…) → UFCS (Uniform Function Call Syntax, iirc)

Array gets sorted, then doubles are removed (uniq) and then everything 
is converted to a string (map).

Everything was recently introduced around 2.059.



More information about the Digitalmars-d mailing list