[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Visibility and upvalues (and macros)
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 29 Jul 1999 08:36:15 -0300 (EST)
>From firstname.lastname@example.org Thu Jul 29 01:58:27 1999
>From: Dave Bollinger <DBollinger@compuserve.com>
>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.
Something like this:
function add(a) retunr function (x) return x+%a end end
this prints (10+1)+(30+20)
> 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?
factorial.lua shows that the standard "functional programming" Y function
is definable in lua. It *is* pretty hard to understand.
I guess there should be a better example in the test directory that uses