Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: closures: anonymous subs vs function templates?

by 5haun (Scribe)
on Dec 21, 2014 at 13:06 UTC ( [id://1110953]=note: print w/replies, xml ) Need Help??


in reply to Re: closures: anonymous subs vs function templates?
in thread closures: anonymous subs vs function templates?

Thank you for the description. When combined with the example from Anonymous Monk, it was helpful in demonstrating the extent of scope of each of the two forms. The lexical form is certainly more limited.
  • Comment on Re^2: closures: anonymous subs vs function templates?

Replies are listed 'Best First'.
Re^3: closures: anonymous subs vs function templates?
by Laurent_R (Canon) on Dec 21, 2014 at 18:22 UTC
    The lexical form is certainly more limited.
    I don't really agree with that sentence. Being able to limit the scope is usually extremely useful. It not only reduces the risk of errors associated with global variables (and other global identifiers), but it also makes it possible to build very powerful constructs.

    Perl 5.0 introduced lexical variables, Perl 5.6 introduced lexical file and directory handles, Perl 5.18 introduced lexical subroutines, the tendency over the years has been to go more and more for lexical "things". Because they add a lot of expressive power to the language.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found