[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Fwd: proper tail calls?
- From: "Nathan Linger" <nathan.linger@...>
- Date: Fri, 10 Mar 2006 16:17:33 -0800
Oops, here is the code.
---------- Forwarded message ----------
From: Nathan Linger <nathan.linger@gmail.com>
Date: Mar 10, 2006 4:16 PM
Subject: proper tail calls?
To: Lua list <lua@bazar2.conectiva.com.br>
>From an enthusiastic new Lua programmer,
I wrote a simple little package for lazy evaluation consisting of just
two functions, delay and force.
I then wrote a simple test program to try it out. It constructs and
traverses an infinite stream, printing out its elements.
I wrote the test program in two styles, procedural and functional.
Due to Lua's proper tail recursion, I expected the two to be
operationally equivalent, but the functional version causes a stack
overflow!
All the code is attached at the end.
What am I to make of this? A bug in my program or in Lua? Just to
clarify, I'm using Lua 5.0.2.
Nathan
Attachment:
thunk.lua
Description: Binary data