lua-users home
lua-l archive

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


On Thu, Jul 19, 2012 at 3:31 AM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
> Note the extra pair of parentheses around foo().

I know about that trick, but I find it idiosyncratic... One more thing
to keep in mind. One small pitfall that could be avoided at literally
no price (remove the check, add a case entry).

I know that it is minor, but AFAIK, you strive to make Lua simple, and
I believe it would simplify the mental model (knowing that tonumber
and tostring never give errors) and make the language a bit
friendlier. A lot of users never see the C side of Lua, and I think
that treating LUA_TNONE in the core libraries as if it were nil would
prevent headaches for a lot of people. For every user that mentions it
here, hundreds are confronted with it but you never hear of them.

The only place where I think it makes sense to make the distinction is
to implement arity-based polymorphism (corner case, where using my
foo() above would be problematic).

As long as there are varargs in the language (to be clear, I don't
want them to go away), people will have the ability to error on TNONE
where TNIL would have made it, but if you don't do it, library authors
will be less likely to do it too. (your coding style influences the
whole Lua ecosystem), and the world will be a better place (err, well,
I may exaggerate a bit here).

That being said, it would also hide bugs that would be catched with
the current way of doing things...

-- Pierre-Yves