Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Is it possible to create a sub exclusive to a sub? (nasty memory leak)

by TedPride (Priest)
on Sep 19, 2004 at 03:49 UTC ( [id://392102]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Is it possible to create a sub exclusive to a sub? (nasty memory leak)
in thread Is it possible to create a sub exclusive to a sub?

Aside from the obvious fact that you don't need a recursive routine to do a fibonacci sequence, I'm still wondering why anonymous subs would ever be preferable to named subs. Is there a measurable speed increase when calling a sub through a pointer rather than a name? Why not just do:
sub fibo { my $inp = shift; $inp > 2 ? &fibo($inp - 1) + &fibo($inp - 2) : 1 }
(for the sake of simplicity, this has been coded so that the nth term IS the nth term)

1) 1
2) 1
3) 2
4) 3

  • Comment on Re^3: Is it possible to create a sub exclusive to a sub? (nasty memory leak)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://392102]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found