Things that may be removed
bearophile
bearophileHUGS at lycos.com
Mon Dec 22 15:10:50 PST 2008
Stewart Gordon:
> How does having built-in sort prevent anybody from implementing sort in a
> library?
The funny thing is they can be syntax-compatible too: in my libs there are sorted() and sort() (the first creates a new array and the second works in-place), they can be used like this:
string[] a2 = ["Liu", "Verylongword", "word", "average"];
a2.sort(&len!(string));
Result:
a2 == ["Liu", "word", "average", "Verylongword"]
Where len() is a refined function template that returns length of lazy/eager iterables, using the .length attribute where possible.
So a2.sort and a2.sort(...)/a2.sorted(...) don't clash.
Bye,
bearophile
More information about the Digitalmars-d
mailing list