delete and references?
Michel Fortin
michel.fortin at michelf.com
Sat Aug 8 08:35:54 PDT 2009
On 2009-08-08 09:17:28 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> Great description.
>
> FWIW, I am trying to convince Walter to not reclaim memory in delete,
> but instead only call destructors. D continues C++'s mistake of
> conflating lifetime termination with memory reclamation.
I don't see how this changes anything. Instead of accessing a
deallocated object, you'll access a finaized but not yet deallocated
object. In both cases, it's a bug.
Wouldn't it be better to have a system to track unique pointers? If you
knew that no other pointer points to a given object or memory block,
you can finalize and deallocate it safely. In fact, the current
semantics of a scope object assume that the programmer will not leave
any dangling pointers at the end of the scope, so it's already assuming
uniqueness, just not enforcing it.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list