lua-users home
lua-l archive

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


On Apr 9, 2005 12:48 PM, Asko Kauppi <asko.kauppi@sci.fi> wrote:
>     if type(v)=="function" then
>         local v2= v()  -- do we get a return value?
>         if v2~=nil then

I'm a little leery of the special treatment of functions, and
specifically of functions returning values, here. Seems like it could
lead to nasty side effects... up until now, adding return values to an
existing Lua function generally hasn't had any side effects on
well-written preexisting code. I understand the increased notational
convenience, but the case of someone needing a switch statement where
some branches return constants and some execute functions is probably
rare. I suggest forcing everything to be function-like and have people
return constants from closures, or not executing anything in a switch
statement (which makes it into a simple table).

Ben