lua-users home
lua-l archive

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

Should __index actually return nil if there is no value, or just not return any value?

The reference manual pseudo code for __index shows an explicit return nil, so I'm guessing that's the proper way.

Is there a subtle semantic difference? Can anyone provide examples of where this would make a difference?

I am particularly interested in the C API case. So instead of return 0, it would be lua_pushnil(L) then return 1.

If it did return 0, would that be bad for the stack? (Wouldn't most calls specify the number of results expected, and get nil anyways?)

Just trying to understand subtleties here.