in reply to Re^10: Use of freed value in iteration
in thread Use of freed value in iteration

"This is pretty much at the heart of the reference-counting model at the heart of perl."
I see what you mean. So do you think that when iterating over values, the refcount of all values being iterated should have their refcount incremented before the loop starts?

Replies are listed 'Best First'.
Re^12: Use of freed value in iteration
by dave_the_m (Monsignor) on Feb 25, 2024 at 22:42 UTC
    So do you think that when iterating over values, the refcount of all values being iterated should have their refcount incremented before the loop starts
    Under PERL_RC_STACK builds (which will eventually become the default), this will happen automatically, as all items will get their reference count incremented when pushed onto the the argument stack (which doesn't happen at the moment). A for loop by default just iterates over a range of items on the stack.

    Dave.