4 ms·
This is why Virgil has support for ranges in the language, which are better than slices. They are value types that represent a subset of a larger array. They ca
by titzer 1y ago
This is why Virgil has support for ranges in the language, which are better than slices. They are value types that represent a subset of a larger array. They can also be off-heap, which allows a Range<byte> to safely refer to memory-mapped buffers.
https://github.com/titzer/virgil/blob/master/doc/tutorial/Ranges.md https://github.com/titzer/virgil/blob/master/doc/tutorial/Ra...
- algorithmsRcool 1y agoIsn't Span<T> the exact same concept?
- titzer 1y agoConceptually they are almost identical, though Virgil has explicit source syntax for making a subrange. One important difference, according to [1] Span<T> can only live on the stack. There are no lifetime restrictions for Range<T> in Virgil. [1] https://learn.microsoft.com/en-us/archive/msdn-magazine/2018/january/csharp-all-about-span-exploring-a-new-net-mainstay https://learn.microsoft.com/en-us/archive/msdn-magazine/2018...
- achandlerwhite 1y agoMemory<T> is the heap compatible version of Span<T> in C# for anyone curious.