Re: set_weak_flag() for objects?

"Stephen R. van den Berg" <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <[email protected]>
Arne Goedeke wrote:
>Weak references are resolved (i.e. objects which only have weak
>references are destructed) only if 1) the gc runs or 2) when a mapping
>is rehashed. This means that in your example the object is only
>destructed when the gc runs. In your situation I would recommend doing
>something like this:

I see.  So because objects only have a reference counter, and not both a
normal and a weak reference counter, it's impractical to trigger an
autodestruct when there are only weak references left.

>class FOO {
>	private mixed _id;

>	mixed `id() {
>		return _id || this;

Well, that would solve it, a bit, at some extra CPU expense, but since
people are likely to set id to an array which in turn might include
a reference to "this" again, it won't solve the essential problem.
I'll revert to destruct()ing instead.
-- 
Stephen.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.