Re: set_weak_flag() for objects?

Arne Goedeke <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <[email protected]>
Maybe in that case a different API makes more sence, for instance by
always passing this and any extra arguments. This would at least deter
users from accidentally creating additional cycles, which can lead to
long GC pauses. Not sure what the priorities are of course.

arne

On 09/21/16 12:58, Stephen R. van den Berg wrote:
> 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.
>
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.