Why can't static arrays be sorted?
Adrian Matoga via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Oct 6 02:24:29 PDT 2016
On Thursday, 6 October 2016 at 09:17:08 UTC, pineapple wrote:
> On Wednesday, 5 October 2016 at 19:30:01 UTC, Jonathan M Davis
> wrote:
>>> Would just like to point out that this is design weirdness on
>>> Phobos' part - the library I've been writing does not have
>>> this problem.
>>
>> It doesn't even make conceptual sense for a static array to be
>> a range, because you can't remove elements from it.
>>
>> - Jonathan M Davis
>
> Just because the static array itself isn't a range doesn't mean
> that it should be necessary to do unintuitive gymnastics with
> it just to pass it to functions like `sort`.
`sort` takes a range. [] gets a range from anything.
It's a convention, not gymnastics.
More information about the Digitalmars-d-learn
mailing list