Re: Using apply with a closure with unbound variables



Thanks for the explanation

By default, LET creates lexical bindings, which means they're only visible to code lexically within its body. Since the body of that closure is outside the LET, it cannot access the local binding. You'd need to declare X special in the LET and the closure for them to find each other (most implementations will do this automatically for the closure, because they can see that there's no surrounding binding of the free variable, but you still have to make it explicit for the LET).

.



Relevant Pages

  • Re: Sort::Maker : anonymous sub is compiled outside of my module
    ... definitely pass a closure into a string eval so this is doable. ... to declare a var in the eval ... --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- ...
    (comp.lang.perl.modules)
  • Re: Using closures with "use strict"
    ... If I define a "use strict" and want to create a closure, ... If you intend to access the same global variable within a different scope ... advantage that you can declare it within smaller blocks as needed, ...
    (comp.lang.perl.misc)
  • Re: commuting?/non-group cipher?
    ... Here, you're not asking explicitly for associativity or closure, but some ... "the elements commute") but all have to do with operations ... Just to be explicit, you mean this for all P, right? ... The set S are all of the permutations described by E, ...
    (sci.crypt)
  • Re: A function that returns a function that adds x to its argument
    ... denoted below by explicit "magic" -- one might write something like ... is something that those languages usually call a "closure". ... in each "new_adder"-created adder, and when one calls the functions ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)
  • Re: Looking for a surjection or R^2
    ... guide us towards a completely explicit function ... of p is a diffeomorphism onto either the upper or the lower half-plane; ... closure of the "bottom" 2-cell, that is, the one that contains the ... up to what *may* be your more exacting standards, ...
    (sci.math)