An exegesis of Walter's reference counted slice

Ivan Timokhin via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 25 01:58:55 PST 2015


Andrei Alexandrescu wrote:

> On 2/24/15 1:33 PM, Ivan Timokhin wrote:
>> Is there any plan to allow safe conversions to T[] (in restricted
>> circumstances, of course)?
> 
> We'd want to avoid it because that would necessitate the whole "scope"
> paraphernalia - e.g you can convert a reference counted slice to
> something like scope(T[]).
> 
> A possible option would be to allow the user to go "I want to use GC
> with this slice from now on" which gives back the T[] and lets the GC
> take care of it.
> 
> But generally I think we should let reference counted slices and
> built-in slices coexist. Generic range-based code is easy to write so
> factoring the nature of the slice away may be an option.
> 
> 
> Andrei

Oh. So, whenever you pass a reference-counted slice around, you need to do 
it with the full inc/dec protocol, which, as Walter has mentioned several 
times already, leads to code bloat and performance hits. So... no to 
efficient reference counting? Also, no slicing of static arrays in @safe 
code?


More information about the Digitalmars-d mailing list