| |
| Posted by jfondren in reply to someone | PermalinkReply |
|
jfondren
Posted in reply to someone
| On Thursday, 24 June 2021 at 02:33:42 UTC, someone wrote:
> On Thursday, 24 June 2021 at 01:36:47 UTC, Ali Çehreli wrote:
> import std.algorithm;
lnumRange.sort!(r"a > b"c);
return lnumRange;
The above works OK. Funny thing indeed, at least to me, totally unexpected.
return lnumRange.sort!(r"a > b"c); /// does not work
return lnumRange.sort!(r"a > b"c).release(); /// works
Intuitive ? Not a bit LoL ! (not complaining at all, just making fun of it)
Most languages have either a void sort that mutates, or a non-mutating
sort that returns the new array. This is true also of similar
languages: C++, Nim, and Rust all void mutate.
So the more experience you have with other languages, probably the
more surprised you'll be by D's sort. This comes up in a few places
with D, like the rest of range support in phobos, or dynamic arrays.
- a thing seems to be a familiar feature
- surprise! it's different in an important way
- (period of grumbling)
- ok, it's useful that it's like this
|