Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: •Re: Re: Toggling between two values

by jdporter (Paladin)
on May 05, 2003 at 20:03 UTC ( [id://255735]=note: print w/replies, xml ) Need Help??


in reply to Re: •Re: Re: Toggling between two values
in thread Toggling between two values

I'm afraid that's not quite true, at least in Perl.
Then Perl has it wrong.
Perl subs that are named are not closures, by fiat.
By fiat? Of whom? ;-)

Merlyn has it right: being a closure and being named are orthogonal properties. OTOH, I'm not saying you are wrong, because you have experience in a strange, quantum-like world (aka perl internals) where the normal definitions don't necessarily apply.

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.

  • Comment on Re: Re: •Re: Re: Toggling between two values

Replies are listed 'Best First'.
Re(5): Toggling between two values
by chip (Curate) on May 05, 2003 at 20:21 UTC
    Well, hm. Given this behavior:
    eval q{ my $foo = 1; sub bar { ++$foo } }; print &bar, &bar, &bar;

    Would you say that &bar is a closure? Because if it is, then I've been conflating closures in general with a specific subset of them, and I have some apologies to make....

        -- Chip Salzenberg, Free-Floating Agent of Chaos

      Would you say that &bar is a closure?
      Yes, it is, according to the standard definition.

      OTOH, there needs to be a term for "subroutine which is created at run time via the sub operator and thus may have bindings to lexicals which outlive the names of those lexicals"...

      jdporter
      The 6th Rule of Perl Club is -- There is no Rule #6.

        Hm. I'd call them "non-trivial closures" or, if I were to use a term from the Perl internals, "cloning closures".

        And, BTW: "Sorry about that, merlyn."

            -- Chip Salzenberg, Free-Floating Agent of Chaos

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found