When should I use SortedRange.release?

Steven Schveighoffer schveiguy at gmail.com
Fri Apr 23 21:34:39 UTC 2021


On 4/23/21 1:35 PM, Bastiaan Veelo wrote:
> For reference, `SortedRange.release` is 
> [documented](https://dlang.org/phobos/std_range.html#.SortedRange) as such:
> 
> "Releases the controlled range and returns it."
> 
> Wow thanks! I love functions that are named exactly as what they do ;-) 
> Seriously though, I still don't know what it is that it does, and why 
> and when it should be done, and when not.
> 
> What happens when a range is released?
> What happens if a range is not released?
> What happens if a range is released more than once?
> 
> And what does "controlled" imply here? In what way has `SortedRange` 
> control over the underlaying data? What can I do and what can't I do to 
> the underlying data as long as `SortedRange` has control?
> 
> My failure to understand this function makes me fear I don't understand 
> `SortedRange` at all, and thereby don't understand how to use 
> `algorithm.sorting` properly.
> 
>

`SortedRange` itself is kind of a kludge of "policy" that isn't fit for 
function.

I use release to get the original data type out (via r.save.release), 
but that's about it.

See my rant about it 
[here](https://forum.dlang.org/post/r7ia94$19uo$1@digitalmars.com)

-Steve


More information about the Digitalmars-d-learn mailing list