lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


 >> the "enclosing" scope might no longer exist when the function is
executed.

   Aha!  It might be executed outside the scope where it was defined.  Duh!

   Thanks, I think that helped.  :-)

   I've become real comfortable with upvalues as backwards references to
overridden functions, but have stopped at about that point.   It seems
then, if I'm on the right track now, that one of the neat "tricks" with
upvalues is using a function to return a newly created function which uses
upvalues - and since it's newly created, the upvalues are "current".  So
each time you call the "creator" function it could return a different
function based on the current value of the thing referenced by the upvalue.

   I need to revisit the factorial.lua test code.  I remember going around
in circles trying to figure that one out!  <grin>  Is this type of "trick"
what you were intending to demonstrate there?

   Cheers,

   Dave