DIP60: @nogc attribute
Michel Fortin via Digitalmars-d
digitalmars-d at puremagic.com
Thu Apr 17 18:58:28 PDT 2014
On 2014-04-17 17:29:02 +0000, Walter Bright <newshound2 at digitalmars.com> said:
> On 4/17/2014 5:34 AM, Manu via Digitalmars-d wrote:
>> People who care would go to the effort of manually marking weak references.
>
> And that's not compatible with having a guarantee of memory safety.
Auto-nulling weak references are perfectly memory-safe. In Objective-C
you use the __weak pointer modifier for that. If you don't want it to
be auto-nulling, use __unsafe_unretained instead to get a raw pointer.
In general, seeing __unsafe_unretained in the code is a red flag
however. You'd better know what you're doing.
If you could transpose the concept to D, __weak would be allowed in
@safe functions while __unsafe_unretained would not. And thus
memory-safety is preserved.
--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca
More information about the Digitalmars-d
mailing list