https://d.puremagic.com/issues/show_bug.cgi?id=10318
--- Comment #8 from [email protected] 2013-12-27 18:04:17 PST --- (In reply to comment #7) > I don't think it's possible to simply infer purity. The D language is able to infer purity for templates. So if sort() is not (wealkly) pure, then there is something that forces it to be not pure. Such parts should be found and fixed. > (2) This may be a non-issue but Phobos cannot sort char[] arrays This is by design. On the other hand sorting char[] is a common need for me (I have not yet had to sort a wchar[]). This works already: void main() { import std.algorithm, std.string; char[] txt = "acb".dup; txt.representation.sort(); assert(txt == "abc"); } But that's not enough, as I'd like to use sort() in UFCS chains too. A simple solution is to add to std.ascii a charsSort() function for this purpose. But then you want charsPartialSort, charsSchwartzSort, etc. And this is a bit too much. So this doesn't seem a very good idea. Another solution is to introduce a unrepresentation() function, opposite of std.string.representation. With it you can write this long code: string txt = "acb; char[] txt2 = txt.dup.representation.sort().release.unrepresentation; Similar code could be written with partialSort, schwartzSort, multiSort, topN, etc. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
