$fib = 7; # Should "Bang!" here
Here you explicit break the circular reference. If you let
$fib
fall out of scope without explicitly breaking the
circular reference the closure would not be destroyed (until global
destruction). (
Lukas Mai's exposition.)
Using assignment to break the circular reference like this is very much a second-class approach.
$fib
.last
, next
, die
,
return
) pass though the statement where the circular
reference is explicitly broken.In practice this mean that if you want to avoid weak references or
local() then you have to put the assignment in an AtExit
object.