in reply to Unpredicted late destruction
You function returns an object, which is a reference to the lexical variable $fn. (Not, not that lexical variable $fn, the other one). $x goes out of scope when leaving fn, but $fn (right, the other one) doesn't, as there's still a reference to it. In the for loop, the reference to $fn (the other one) is aliased to $fn (right, that one). It isn't until the end of the loop that $fn (that one) is no longer an alias for a reference to $fn (not that one, the other one). At that moment, there's no reference to $fh (the other one) anymore, so the object is destroyed.
Next time, please pick some none colliding variable names.
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Unpredicted late destruction
by broquaint (Abbot) on Nov 05, 2003 at 17:55 UTC | |
by ferrency (Deacon) on Nov 12, 2003 at 15:36 UTC | |
|
Re: Re: Unpredicted late destruction
by ferrency (Deacon) on Nov 05, 2003 at 17:51 UTC |