RCArray is unsafe
Zach the Mystic via Digitalmars-d
digitalmars-d at puremagic.com
Wed Mar 4 09:44:01 PST 2015
On Wednesday, 4 March 2015 at 07:50:50 UTC, Manu wrote:
> Well you can't get to a subcomponent if not through it's owner.
> If the question is about passing RC objects members to
> functions, then
> the solution is the same as above, the stack needs a reference
> to the
> parent before it can pass a pointer to it's member down the
> line for
> the same reasons.
Yeah, or you could mimic such a reference by wrapping the call in
an addRef/release cycle, as a performance optimization.
> The trouble then is what if that member pointer escapes? Well
> I'd
> imagine that it needs to be a scope pointer (I think we all
> agree RC
> relies on scope). So a raw pointer to some member of an RC
> object must
> be scope(*).
I have a whole Reference Safety System which doesn't need
explicit scope because it incorporates it implicitly:
http://forum.dlang.org/post/offurllmuxjewizxedab@forum.dlang.org
> That it can't escape, combined with knowledge that the
> stack has a reference to it's owner, guarantees that it won't
> disappear.
I think you and I are on the same page.
More information about the Digitalmars-d
mailing list