Re:Friendship ended with the garbage collector
by rwmj on Friday August 27, 2021 @06:48AM
(#28326199)
Your solution to the supposed overhead of garbage collection is to make every single object fat and have an extra test every time a pointer to an object is dropped?
[ Parent
| on HN ]
Re:Friendship ended with the garbage collector
by js8 on Friday August 27, 2021 @06:53AM
(#28326245)
No, the handler(s) would only be called when the owner wants to dispose the object and there are still references to it.
Re:Friendship ended with the garbage collector
by rwmj on Friday August 27, 2021 @06:59AM
(#28326274)
How do you know there are still references without counting them somewhere or inspecting all other objects? And what would the handler really do? What common code has other owners willing to take over ownership (and you have to handle this problem recursively too).
Re:Friendship ended with the garbage collector
by js8 on Friday August 27, 2021 @09:10AM
(#28327357)
In the article, they already assume reference counting of references, see the previous paragraph:
"When the reference goes out of scope, the count is reduced. When an owned value goes out of scope and its reference count is not zero, the program terminates with an error (which I'll refer to as a "panic")."