lua-users home
lua-l archive

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



On Thu, 13 Jul 2000, Falko Poiker wrote:

> <snip>
> >>--------------------------------
> >>$debug
> >>
> >>myFunc = function ()
> >>  Test = {}
> >>  function Test:init() end
> >>end
> >>--------------------------------
> <snip>
> >Personally I think the code [above] is sensible and clean --- it would be
> >nice if the language would allow it.
> 
> I'm curious:  How could you consider declaring and calling a function, all
> in the middle of the declaration of another function, clean and sensible?
> 
> Falko
> 
Why would it be a problem to define and use a function just about
anywhere? Isn't that what having function be a first class object is all
about? As for specific uses, there are many. For example smalltalk often
uses something similar (a block, which is technically a full context in
many versions of the language) as an iteration function over an array or
other collection.

If pushed I'm sure I can come up with specific examples in Lua, though
I've only played around with the language a little bit, and will be glad
to do so if anyone feels it's necessary.

  - Tom Wrensch