Sebastian Graf:

Plus, the compiler is still able to optimize most of the delegate/range fluff away (as opposed to e.g. C#).

There are several optimizations that D/DMD is not performing on those ranges and higher order functions. The Haskell compiler GHC optimized that stuff using purity, library defined "rewrite rules", stream fusion/deforestation and more. DMD does nothing of this, or very little. I think so far Walter has shown no interest in this.


I'm all for more algorithm primitives in std.algorithm. I missed classify often enough and coming from a C# backgroung I was confused that std.algorithm.group did not what I thought it did.

and coming from a C# backgroung I was confused that std.algorithm.group did not what I thought it did.

The "group" of Phobos is useful and it has purposes quite different from the Perl6 "classify", both are needed. I have also suggested "group" to act more like the Python "itertools.grouby" and yield not just the (head,count) tuples, but (head,lazy_range_of_the_equality_ class) that is quite useful, example:


from itertools import groupby
s = "abABACAaaaaBCAB"
[(h, list(g)) for h,g in groupby(s, key=str.isupper)]
[(False, ['a', 'b']), (True, ['A', 'B', 'A', 'C', 'A']), (False, ['a', 'a', 'a', 'a']), (True, ['B', 'C', 'A', 'B'])]

I think Andrei was looking at this change with interest. Changing Phobos group() API now is maybe not easy to do, so maybe it's better to introduce a differently named function for that, like one named "groupAll" or something similar.


Is there any reason why you keep using quoted strings instead of string literals for lambdas besides taste?

My editor uses a single uniform color for the contents of normal strings, unlike quoted strings.

Bye,
bearophile

Reply via email to