in reply to Re^4: Advice on transforming a sub into a re-entrant recursive-able method.
in thread Advice on transforming a sub into a re-entrant recursive-able method.
because sometimes the usefulness of being able to call a function recursively will be a surprise
It doesn't make any sense to try to follow advice if you don't know what it means. Your original function does one fairly simple thing. I think it's highly unlikely that it will ever need to be called recursively. If it turns out that that it will, the function is already in pretty good shape, because it uses no external variables (that is, it accesses no global variables and no external lexical variables). However, it does depend on external state — specifically, the state stored in the snmp session object; and also whatever is read from the snmp space via the snmp session object. These factors suggest that making this function re-entrant may be complicated, and it's quite likely that your little function isn't the right place to solve the problem. On the other hand, the data from snmp space may be relatively static, and the snmp session may be a well-behaved black box (storing no state that would impact your function). If this is the case, then your function is already as recursion-ready as it needs to be. If you didn't figure out all this yourself, then probably you should simply skip that nugget of wisdom from HOP, for now.
See also: voodoo programming and You aren't gonna need it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Advice on transforming a sub into a re-entrant recursive-able method.
by hechz (Novice) on Jul 21, 2008 at 19:57 UTC | |
by jdporter (Paladin) on Jul 21, 2008 at 20:16 UTC | |
by hechz (Novice) on Jul 21, 2008 at 20:30 UTC |