Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Why are closures cool, continued?

by mr.dunstan (Monk)
on Jan 19, 2002 at 04:11 UTC ( #140011=note: print w/replies, xml ) Need Help??

in reply to Why are closures cool, continued?

Ok how about this: true or false (the author of the very first example in this thread and I were talking thru what constitutes this) ...

"A closure is different from an anonymous subroutine in that (instead of having private variables) it -saves- the variables passed into it in its scope!"

This seems like a reasonable enough and perfectly clear statement, but to be honest anytime I think something is reasonable and clear, that's when I'm about to start being REALLY wrong! :)


Replies are listed 'Best First'.
Re: Re: Why are closures cool, continued?
by perrin (Chancellor) on Jan 19, 2002 at 06:36 UTC
    Closure and anonymous sub -- two totally different things! An anonymous sub is a ref to a sub without a name. A closure is any sub (named or not) that refers to lexical variables defined outside of its scope.
      Nearly. An anonymous sub is a sub without a name that can only be accessed via a reference (to that sub).

      g r i n d e r
      print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u';

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://140011]
[choroba]: ambrus But pm-cb-g need sto stay logged in
[Discipulus]: infact my tk client is unable to connect at the moment
[ambrus]: choroba: that doesn't matter, the cookies are independent on the webserver, they just have to contain your username and crypted password with a seed of the user's choice, you can change the hostname or even construct a cookie without asking the server

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2017-10-24 11:27 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (289 votes). Check out past polls.