Formal Review of std.range.ndslice

Ilya Yaroshenko via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 21 13:00:55 PST 2015


On Friday, 20 November 2015 at 21:55:18 UTC, Andrei Alexandrescu 
wrote:
> On 11/20/15 4:23 PM, Jack Stouffer wrote:
>> On Friday, 20 November 2015 at 20:33:27 UTC, Ilya wrote:
>>> Great! Added to PR's TODO list :-)
>>
>> This will be interesting because there is no defined idiomatic 
>> usage of
>> std.allocator. I imagine std.range.ndslice will be the 
>> trend-setter for
>> Phobos in this regard.
>
> There's the persistent list example that I posted on dpaste a 
> couple weeks back. I do expect things to evolve a bit before 
> stabilizing.
>
> BTW thanks Jack for reaching out via email.
>
>
> Andrei

After playing with memory allocation I became convinced that 
ndslice package should not have any kind of memory allocation 
(except opCast to array) at least we will add allocators support 
to std.array. The most important function is std.array.array.

Out of the box user can do `auto slice = new 
int[2*3*4+n].sliced(2, 3, 4); //n>=0`.
The link below contains convenience functions in examples for 
`sliced`
1. `createSlice` creates an GC allocated slice
2. `ndarray` creates GC allocated ndarray copy of a slice
3.  `makeSlice` make slice with allocators

They are only examples and not a part of the API.

http://dtest.thecybershadow.net/artifact/website-20b34f54aaeb876b545bac1d34b954db15f0a237-0d1a48cd3d6cc5a31c97ba84a93229e4/web/phobos-prerelease/std_experimental_ndslice_slice.html#.sliced

--Ilya


More information about the Digitalmars-d mailing list