.NET introduces Span<T>, basically D slices

Guy justanotherguy at gmail.com
Sun Nov 26 05:36:15 UTC 2017


On Tuesday, 21 November 2017 at 19:39:19 UTC, flamencofantasy 
wrote:
> On Sunday, 19 November 2017 at 14:46:32 UTC, Rumbu wrote:
>> On Sunday, 19 November 2017 at 02:16:36 UTC, Luís Marques 
>> wrote:
>>> https://github.com/dotnet/corefxlab/blob/master/docs/specs/span.md
>>>
>>> Seems like D wisdom is creeping in. For instance, the Data 
>>> Pipelines section basically explains why ranges/slices and 
>>> algorithms are nice and relevant: 
>>> <https://github.com/dotnet/corefxlab/blob/master/docs/specs/span.md#data-pipelines>
>>
>> Sorry to disappoint, but Span<T> is something else. The .net 
>> equivalent of D slices is in fact the not so popular 
>> ArraySegment<T> available in .net since 2008.
>>
>> Span<T> will allow access to unmanaged and stack memory in the 
>> same way as using a standard array.
>
> Actually Span<T> is a lot more like D slices in that it can use 
> any type of memory.
> ArraySegment<T> can only be initialized with an array type and 
> thus is very far from being like a D slice.
> I use D slices exclusively with non-GC memory or mapped files 
> and similarly I can now make use of Span<T> but I was never 
> able to employ ArraySegment<T>.

It's funny you say that because they just announced the 
introduction of ranges and I believe they return Spans.


More information about the Digitalmars-d mailing list