[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Recursive local functions
- From: Reuben Thomas <rrt1001@...>
- Date: Thu, 4 Jan 2001 17:53:15 +0000 (GMT)
> > 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)