Collections question

Marc Schütz via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 1 06:35:07 PST 2015


On Tuesday, 1 December 2015 at 14:15:47 UTC, Andrei Alexandrescu 
wrote:
> On 12/1/15 4:55 AM, Marc Schütz wrote:
>> On Monday, 30 November 2015 at 18:18:38 UTC, Andrei 
>> Alexandrescu wrote:
>>> * The one matter with the value/RefCounted approach is that 
>>> RefCounted
>>> cannot be made @safe.
>>
>> That's just as true for internal refcounting.
>
> I don't think that's the case. The way I wrote code, safety can 
> be achieved with a few controlled insertions of @trusted. -- 
> Andrei

As long as you can pass the container and one of it's elements by 
mutable ref, it's unsafe (see the RCArray discussion [1]). If you 
can only access the elements by value (i.e. opIndex returns a 
copy), this precondition isn't fulfilled, but otherwise, I see no 
way to prevent it with the current language.

[1] 
http://forum.dlang.org/post/huspgmeupgobjubtsmfe@forum.dlang.org


More information about the Digitalmars-d mailing list