@safety of Array
monarch_dodra via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 13 13:28:35 PDT 2014
On Monday, 13 October 2014 at 17:16:40 UTC, Brad Roberts via
Digitalmars-d wrote:
> On 10/13/2014 7:47 AM, Andrei Alexandrescu via Digitalmars-d
> wrote:
>> On 10/12/14, 5:41 PM, Brad Roberts via Digitalmars-d wrote:
>>> I know it's a tricky implementation, but let's focus on the
>>> goal..
>>> should Array be usable in @safe code?
>>
>> Yes. In order for that to be 100% automatically checkable, we
>> need the
>> rules restricting escape of addresses of returns by reference.
>> -- Andrei
>
> 100% checkable isn't required right now. For it to be used in
> an @safe context all that's needed is liberal use of @trusted.
> That can be refined over time to a more checked version. We
> shouldn't wait for checkability.
>
> Will one of you experts in the impl of Array volunteer to make
> the appropriate changes?
The issue is that it's *not* safe though. You can escape the
reference, destroy it, and end up with a dangling pointer.
Arbitrarily marking things as trusted seriously undermines what
safe means. @trusted should be used with extreme caution.
More information about the Digitalmars-d
mailing list