lua-users home
lua-l archive

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


I need an edit button. So the first example doesn't work but the second one DOES.

Robert

----- Original Message -----
> From: "Robert Virding" <robert.virding@erlang-solutions.com>
> To: "Lua mailing list" <lua-l@lists.lua.org>
> Sent: Wednesday, 21 November, 2012 1:15:24 AM
> Subject: Re: Forward function declarations - relocal command
> 
> Sorry I don't WHY there is a problem. I assume I would get the same
> effect with a recursive function. So
> 
> local f
> local f = function () <ref to f> end
> 
> doesn't work but the following doesn't
> 
> local f
> f = function () <ref to f> end
> 
> The second one is from the 5.2 manual as the expansion for
> 
> local function f () <ref to f> end
> 
> Why is it like that? Does it need to be like that? Have I missed
> something in the manual? Or is it just an implementation detail?
> 
> Robert
> 
> ----- Original Message -----
> > From: "Roberto Ierusalimschy" <roberto@inf.puc-rio.br>
> > To: "Lua mailing list" <lua-l@lists.lua.org>
> > Sent: Monday, 19 November, 2012 1:58:21 PM
> > Subject: Re: Forward function declarations - relocal command
> > 
> > > How do other people deal with forward declarations?
> > 
> > I tend to define any function before using it, so I only need a
> > forward
> > declaration when the code has indirect recursion. Even in that
> > case,
> > I try to minimize the backward edges in the call graph. (For
> > instance,
> > the Lua parser has only two forward declarations, one for 'expr'
> > (expressions) and one for 'statement', which correspond to the main
> > recursive non-terminals in the grammar.)
> > 
> > In the few cases left, I think comments should be enough.
> > 
> > -- Roberto
> > 
> > 
> 
>