in reply to Wide open Closures?
Are there any negative effects to closing around many lexicals, or is this another instance of Perl "magic" that ultimately makes no difference?
Negative effects in terms of what? You seem to want those 50 variables to hang around in memory, which the closure will do just as well as a global variable. On top of that, you get encapsulation that you don't get with a global variable. I'm not sure what would be magic, though; Perl treats one closed-over lexical variable the same as 50.
Update: I seem to have misunderstood your question a bit. You only want those three variables to stick around? In that case, dave_the_m's comment should be particularly relevant.
Another thing I noticed is you mention a "normal routine". Do you mean a named subroutine as opposed to an anonymous subroutine? Keep in mind named subroutines create closures too, so I'm not sure how much relevance that distinction would have.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Wide open Closures?
by eff_i_g (Curate) on Dec 02, 2005 at 18:15 UTC |