good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I don't follow you on the advantage or reason for only using the closed-over variable in one place, that being a function that returns it. It is largely about scope management and making sure you control how many refs a given object might have. Here is some example (NOTE: I have not run this to confirm it works exactly as expected, but you should get the idea of you are familar with MooseX::Role::Parameterized) So, first let me say that this is likely overkill, but having had some nasty ref-counting leaks in the past I have learned to be cautious. So as you can see here, the 'static_something' method I am creating only closes over the $something variable, which we know is a string. If I had written 'static_something' like so: Then the method would close over the $p object, which *might* become a source of leaks. Like I said, probably overkill, but I prefer to be cautious in this kind of environment.
-stvn
In reply to Re^7: Moose: What about "class" attributes?
by stvn
|
|