Ah, the copying part, yes - but then again if I'm doing that, I'd expect to be doing so in order to access A at which point I already needed that bit of memory.
The collection thing I can definitely see though.
One thing I've never quite worked out is - without reference counting, how do you handle timely destruction?
I know that if I do something like:
{
my $x = foo();
...
}
then $x will be destroyed at the exact point the } is hit, or that an exception unwinds the stack past this point. That lets me do all sorts of nice things like rolling back a transaction automatically, throwing a warning if some task was expected to be completed but hasn't been, and other bits and pieces.In a mark-and-sweep GC language, presumably there's some other additional feature that needs to be implemented in order to provide this?