Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: local & global function (closures)

by LanX (Saint)
on Oct 17, 2018 at 12:30 UTC ( [id://1224156]=note: print w/replies, xml ) Need Help??


in reply to Re: local & global function
in thread local & global function

> The two functions are defined in a block and therefore share the lexical

Additional note: this is a fine example for using Closures.

The two functions are "closing" over the lexical variable $test.

And this $test has a lexical (i.e. static) scope restricted to the block.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

PS: it also demonstrates that closure don't need to be anonymous. There is a widespread misconception in some other languages that "closure" is a synonym for "anonymous function".

  • Comment on Re^2: local & global function (closures)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-25 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found