Steven N. Hirsch <[EMAIL PROTECTED]> writes:
>> >
>> >DESTROY is not necessarily called at the time the refcount hits zero.  
>> 
>> Yes it is.
>> 
>> >Perl cleans up objects without references only when leaving a scope.  
>> 
>> i.e. that is when it decrements the REFCOUNT (in the FREETMPS/LEAVE). 
>
>D'oh.  Sorry, I confused things with the way 'mortal' objects are treated.  
>Unless I really _am_ growing senile, aren't these recorded on a list of 
>things to be cleaned up on exit from a scope?

Yes. And "cleaned up" means doing an SvREFCOUNT_dec().
If when that is done count is zero the DESTROY happens. 
But if something else has incremented REFCOUNT then SV lives on.

e.g. this makes 

foo($a.$b) # pass a mortal as 1st arg
; # mortals cleaned up on ';'  


sub foo
{
  push @save,$_[0];    # REFCOUNT up
  ...
}


Reply via email to