sort API design

Dukc ajieskola at gmail.com
Wed Nov 20 13:15:12 UTC 2019


On Wednesday, 20 November 2019 at 09:33:25 UTC, Johannes Riecken 
wrote:
> Later I learned that I was trapped by `sort` being in-place but 
> still returning a value. If this API were to be designed from 
> scratch, I wonder if it would be possible to rule out this 
> incorrect usage at compile-time while still retaining the other 
> nice features of the `sort` function like being in-place and 
> giving strong types which can be used to choose faster 
> algorithms to further transform the result, etc.?

Theoretically it could do the same thing as `std.algortihm.move` 
- assign the original range to it's init value, so if it's 
accidently reused it'd be more obvious. But of course it won't be 
worth doing anymore because of the breakage. Perhaps in the std 
v2 Wilzbach has talked about, if the authors so wish.


More information about the Digitalmars-d mailing list