On 2014-05-11 08:29:13 +0000, Walter Bright <[email protected]> said:

Again, O-C and C++/CX ARC are not memory safe because in order to make it perform they provide unsafe escapes from it.

But D could provide memory-safe escapes. If we keep the current GC to collect cycles, we could also allow raw pointers managed by the GC alongside ARC.

Let's say we have two kinds of pointers: rc+gc pointers (the default) and gc_only pointers (on demand). When assigning from a rc+gc pointer to a gc_only pointer, the compiler emits code that disables destruction via the reference counting. This makes the GC solely responsible for destructing and deallocating that memory block. You can still assign the pointer to a rc+gc pointer later on, but the reference count is no longer reliable which is why RC-based destruction has been disabled.

--
Michel Fortin
[email protected]
http://michelf.ca

Reply via email to