On 1 March 2011 11:30, Gunnar Zötl
<gz@tset.de> wrote:
> The most frequent use of gettop and isnone in C lua libraries to
> modify what a function does really disturbs me.
Is there a source for that claim? I'd reckon that the most frequent use of these is to do optional/variable arguments, and checking wether you got the correct number of arguments. At least that's what I do with those.
> foo(nil,nil,nil) should be the same as foo(nil,nil) and foo() etc
Nope, it should not. Passing three nils is not the same as passing nothing at all.
> What steps can we take to discourage the writing, and usage of libraries that do such evil?
Could you name a few, please?
Gunnar
Actually Daurnimator does have a valid point, which maybe should require a note to the functions it effects.
I would personally say that table.insert(t,1,k) and table.insert(t,k,nil) under Lua rules should behave the same. The problem is the function is doing too much and would require a separate C function which I do not think is going to happen. The biggest problem I see with tinsert is that extra parameters ie greater than three cause an error, are there any other Lua C functions that do not ignore extra parameters?