[Issue 5076] std.algorithm.sorted / schwartzSorted

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 7 12:20:10 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=5076


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #13 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-02-07 12:20:02 PST ---
I run into this issue all the time, in particular when doing script-based
programming. E.g.:

string[string] classes;
foreach (name; classes.keys.sorted) { } // ng

Having to do this is a chore:
auto keys = classes.keys;
sort(keys);
foreach (name; keys) { } 

This works ok for my purposes (yada yada about constraints):
T sorted(T)(T t)
{
    T result = t;
    sort(result);
    return result;
}

Why do we have replace and replaceInPlace, whereas we have sort which sorts in
place implicitly? "findSkip" is another function that I sometimes use but I
hate how it hides the fact that it modifies its arguments. "find" returns a
range, but "findSkip" returns a bool and *modifies* your argument. It's not at
all obvious from the call site.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list