lua-users home
lua-l archive

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


Scheme provides a delay function.  You can see an implementation at SRFI-45, and some uses of that delay function at SRFI-41.  Even if the Scheme code isn't directly portable to Lua, the explanations should give you some good ideas.

Phil

On Fri, Oct 29, 2010 at 4:44 AM, Johnson Lin <arch.jslin@gmail.com> wrote:
This might be a n00b question, but..

I know Lua is using strict/eager evaluation, but I found some posts on
the list, saying that it should be possible to implement a "delay"
function in plain Lua to imitate lazy evaluation. However It seems
that I can't find even a single simple example on the web that does
anything close to this. I'm just curious what approach would you take
if you were to implement something that can mimic lazy evaluation.
It's not like memoization techniques or lazy tables. I can't find a
way to truly make a generic _expression_ or function invocation lazy
with lazy tables.

Thanks in advance for any suggesstions : )