On Wednesday, 12 April 2017 at 15:08:44 UTC, Nick Treleaven wrote:
This should be recognised as a scope class instance. It doesn't need reference counting, as it should always be destroyed at the end of current scope.

The reason it needs:

{   scope Object ob = new RefCountableType("foo");
    scope ob2 = ob;
    ob = new RefCountableType("bar");
}

The "foo" instance would leak if the destruction would be done by calling at end of scope. You also cannot call the destructor when a new object is assigned to it, because then ob2 would become dangling.

What could act without GC or RC, is an immutable scoped object. But that's a different matter altogether, because throwing lifetimed objects did not work according to Walter.

Reply via email to