On Wednesday, 9 October 2013 at 00:00:09 UTC, ponce wrote:
Resource Guard?

Actually, I've been coming to see the gc as being an implementation detail for immutability, and memory safety is a secondary piece.

With immutable though, you are guaranteeing that the contents never change. Never change means the memory must never be reused either - thus never freed.

But we want to reclaim that resource if we can. The GC lets us do that without ever breaking the guarantee of immutability.


To this end, I really, really want to see the scope parameter (and return value!) thing implemented. All mutable and const slices and pointers would be assumed to be scope (or if this breaks too much code, strongly recommended to be scope at all times). That way, you won't let the reference escape, meaning it is safe to manage those resources with destructors on the outer layer, while using them for cheap on inner layers by just passing the pointer, which can even be implicit, iff scope.

Those wouldn't need the gc.

Immutable resources, however, are always safe to store, so scope immutable would be irrelevant. This illusion is maintained with the gc.

Reply via email to