lua-users home
lua-l archive

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


> > I agree that a language solution would be nice, but I can't see one nor can I
> > see a real need for this. How common are such recursive functions?
>
> Often, if you write the evil code I do ;-)

I came across exactly this problem a few days ago, while writing a parser
for Scheme. I wanted to share some state (the string being parsed) between
two mutually recursive functions (one to parse an atom, one to parse a
list). This naturally led to wrapping up the two functions in an outer
function which was passed the string to parse.

Recursion is very common if you program in a functional style, and since
there's no let...in... construct in Lua, wrapping up functions in order to
use upvalues is a nice way to do implicit parameters. So I would imagine
this problem being quite common.

-- 
http://sc3d.org/rrt/ | wit, n.  educated insolence (Aristotle)