Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube

by hippo (Archbishop)
on Jul 30, 2025 at 18:00 UTC ( [id://11165875]=note: print w/replies, xml ) Need Help??


in reply to Re: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube
in thread Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube

Other languages seem to use it other ways, including to mean any anonymous ... sub.

If an anonymous sub doesn't close over an external variable then it isn't a closure. The clue is in the name. :-)


🦛

  • Comment on Re^2: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube

Replies are listed 'Best First'.
Re^3: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube (UPDATE Etymology)
by LanX (Saint) on Jul 30, 2025 at 18:09 UTC
    > If an anonymous sub doesn't close over an external variable then it isn't a closure.

    And if a named sub does, it's also a closure.

    Indeed two unrelated concepts.

    UPDATE

    I just checked the etymology, the fact that the bound variables are not accessible from the outside of their defining scope makes the sub "closed".

    { my $state = 42; sub closed_sub { return $state++; } } say closed_sub(); # 42 say closed_sub(); # 43

    Contrary to subs binding global variables, which are "open".

    { our $state = 42; sub open_sub { return $state++; } } say open_sub(); # 42 $main::state = 666; say open_sub(); # 666

    (of course Perl allows you to bind both kinds, so it's not an exclusive attribute here)

    see references from WP:

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2026-03-08 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.