Why can't static arrays be sorted?

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 6 02:23:19 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`.

I mean, people post here how often asking why static or dynamic 
arrays aren't being accepted by Phobos' range functions in their 
code?

Maybe Phobos really ought to consider another approach. Accepting 
things that are _valid_ as ranges and not only things that are 
ranges themselves has proven to be an effective strategy in mach.



More information about the Digitalmars-d-learn mailing list