Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Attempting to use $_ in "sub" inside "map"

by LanX (Saint)
on May 08, 2021 at 07:55 UTC ( [id://11132262]=note: print w/replies, xml ) Need Help??


in reply to Re: Attempting to use $_ in "sub" inside "map" (updated)
in thread Attempting to use $_ in "sub" inside "map"

> is to form a closure | lexical closure (if that's the proper terminology)

I'm pretty sure both are correct. I have trouble to imagine closed over variables which are not lexical. (I usually call those global ;-)

Personally I'd use "lexical closure" to disambiguate, if there is another interpretation of "closure" in the context.

The same way we use "file-glob" and "type-glob" to distinguish between glob and the * sigil

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

Replies are listed 'Best First'.
Re^3: Attempting to use $_ in "sub" inside "map"
by AnomalousMonk (Archbishop) on May 08, 2021 at 09:47 UTC
    I have trouble to imagine closed over variables which are not lexical.

    Yeah, I was thinking about it after posting and I couldn't come up with an example of non-lexical closure either. I'll just add a link to the Wikipedia article and let everyone else figure it out. :)


    Give a man a fish:  <%-{-{-{-<

Re^3: Attempting to use $_ in "sub" inside "map"
by tobyink (Canon) on May 10, 2021 at 14:30 UTC

    In languages without lexically scoped variables or something approximating them, there's not really any such thing as a closure. You can still have first-class functions (i.e. coderefs); they just have no need to close over anything.

      > first-class functions (i.e. coderefs)

      Doesn't equal closures. OK PHP is using that terminology, but it's wrong ...

      ... anyway who's using PHP anymore ;-)

      > In languages without lexically scoped variables or something approximating them

      do you have an example for such a language with functions as first class objects?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      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://11132262]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-24 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found