An exegesis of Walter's reference counted slice

via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 25 03:23:28 PST 2015


On Tuesday, 24 February 2015 at 22:11:36 UTC, Andrei Alexandrescu 
wrote:
> On 2/24/15 1:55 PM, "Marc =?UTF-8?B?U2Now7x0eiI=?= 
> <schuetzm at gmx.net>" wrote:
>> On Tuesday, 24 February 2015 at 19:40:35 UTC, Andrei 
>> Alexandrescu wrote:
>>> So: does DIP25 allow safe slices? Looks that way
>>
>> I believe it does, but at the cost of forced reference 
>> counting. As I
>> pointed out, the `ref` solution
>
> What is the ref solution?
>

DIP25, in that it applies the semantics of `scope` to `ref`. The 
safety gained is thereby restricted to `ref`, but does not apply 
to slices, pointers and class references. That's the reason - as 
you already replied to Ivan - that RCArray cannot return a real 
slice.

>> is not applicable to slices, therefore
>> it needs to return an RCArray. This in turn forces an inc/dec 
>> whenever
>> it is sliced or copied, and - maybe worse - it requires all 
>> consumers to
>> support RCArray (or whatever other idiosyncratic RC 
>> implementation users
>> come up with).
>
> It seems to me it's time to have a UniqueArray proof of concept.

How is that related to what I wrote above?


More information about the Digitalmars-d mailing list