[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Scheme's "delay" function in plain Lua?
- From: Michal Kottman <k0mpjut0r@...>
- Date: Fri, 29 Oct 2010 23:32:49 +0200
On Fri, 2010-10-29 at 12:42 -0700, Jonathan Castello wrote:
> On Fri, Oct 29, 2010 at 4:27 AM, Michal Kottman <k0mpjut0r@gmail.com> wrote:
> > function delay(exp)
> > local f = assert(loadstring("return function() return " .. exp .. "
> > end"))()
> > -- TODO: setup the env of f to lookup local variables
> > return f
> > end
>
> Wouldn't this work without the extra function + call?
>
> local f = assert(loadstring("return " .. exp))
> -- setup the env of f
> return f
True, it would, I wasn't thinking at the time... :)