[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Recursive anonymous functions?
- From: "Aaron Brown" <aaron-lua@...>
- Date: Thu, 22 Jul 2004 16:34:19 -0400
Bennett wrote:
> To allow an anoymous function to call itself, you can use
> a lexical closure to provide the ability to recurse:
If I understand what you're doing (maybe I don't, since I
don't know Perl) then the equivalent in Lua would be:
local foo
do
lexicalfoo = function()
print "I am boring"
lexicalfoo()
end -- lexicalfoo
foo = lexicalfoo
end -- do
foo()
When foo is called, lexicalfoo no longer exists.
But it seems to me that the whole point of asking whether
anonymous functions can recurse is to find out whether they
can recurse without giving them names. Of course a function
will be able to recurse if you give it a name and use that
name to make the recursive call.
--
Aaron