On 07/19/2012 04:21 PM, Petr Janda wrote:
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?

Then it is mapped to string representations, just as the code says.

What type is x?

'int', if you like.

What kind of operator is =>,

Lambda function. It is the same as (...){ return ...; }, just without the noise.

why is x.to!string allowed template specialization should say
x.to!(string),

Why should it say that?

which leads me to think that there are multiple syntaxes
for things

There always are 'multiple syntaxes for things' if writing code should
be productive and validating code for static correctness should be
decidable.

(why I hate dynamic languages, love compiled)


This is unrelated to dynamic vs. compiled. (those two terms do not
contradict each other anyway.)

On another note, (copied from wikipedia)

foreach(item; set) {
// do something to item
}

what's with the lax syntax being allowed?

s/lax/to the point/

Shouldn't it be at least specified "auto item"?


Why on earth would that be the case?

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.

It's just syntax. Eliminating syntax noise is fine. Code should look
like what it does.

Reply via email to