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.