On Monday, 31 December 2012 at 12:36:06 UTC, monarch_dodra wrote:
On Monday, 31 December 2012 at 12:14:22 UTC, Sven Over wrote:
A smart-pointer type for arrays can easily provide slices. It
keeps a reference to the full array (which gets destructed
when the last reference is dropped), but addresses a subrange.
I think the problem would be if you try to append to the slice
(~): If the underlying array is not GC allocated, then it will
append to a new GC allocated array (AFAIK).
As long as you don't append, I'd say you are fine.
Of course your smart-array-pointer type needs to implement the ~
operator and create a copy of the array in that case. I guess the
full implementation would include something that would resemble
that of std::vector in C++.
I should get started writing those types. Then I could either
demonstrate that it does work, or understand that it doesn't (and
why).