lua-users home
lua-l archive

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

The core functions behaves like this in other places too. tostring(), for example, errors when passed 0 arguments, even when, syntactically, it looks like something was passed.

function foo()end
tostring( foo() ) --> error.

contrast with:
nil == foo() --> true
t={}; tostring( t[1] ) --> nil

In most places, Lua converts a lack of value to nil, but not in function calls (stacks (or stack references?) are passed around in that context). Since C functions are always varargs, they can, and in the case of the core functions, do check the length of the stack.

 I've pleaded for a more forgiving behavour in the past, but the authors think that the current behavior is appropriate and well documented.

-- Pierre-Yves

On Wed, Jul 18, 2012 at 10:36 PM, Sir Pogsalot <> wrote:
Earlier I was trying to pass around the reference to rawset where it would be called by an iterator with the form: rawset(some_table, k)


some_iter(some_table, rawset) was what that looked like.

Unfortunately it looks like rawset() doesn't like being called with its third argument being "nothing" and not nil.  Would it be possible for Lua upstream to have it instead coerce nothing to nil?  I know I can simply wrap rawset(), I just think this /should/ be allowed by rawset.

Open to suggestions, someone told me the *error* is there in place someone mistakenly typo'd and meant to call rawset() with a third arg, I disagree that this is appropriate though. ;>

Later... ^__^