On Friday, 27 May 2016 at 21:51:59 UTC, Seb wrote:
not if [] would be ref-counted too ;-)

That would be kinda horrible. Right now, slicing is virtually free and compatible with all kinds of backing schemes. If it became refcounted, it'd:

1) have to keep a pointer to the refcount structure with the slice, adding memory cost

2) make assignments and slicing work through that refcount pointer, adding cpu cost

3) somehow need to know the appropriate freeing strategy, adding some kind of indirect call when refcount = 0, and would make creating a slice more tedious as you'd need to know this (meaning you also probably need to allocate this structure! no more free ptr[0 .. length] operation on malloc'd blocks.)


So I'd be pretty strongly against that.

Reply via email to