lua-users home
lua-l archive

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


Hi

2018-03-19 16:28 GMT-03:00 Dirk Laurie <dirk.laurie@gmail.com>:
2018-03-19 21:08 GMT+02:00 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:

> More concretely, I propose a little experiment: suppose that Lua raises
> a run-time error for every assignment of nils to tables except in
> explicit assignments with a constant nil (t[k]=nil). How frequently this
> error will occurr without hinting a hidden bug in the code?

Including, of course, var=uninit where "var" is global and "uninit" is
an uninitialized global?

My first reaction was that it occurs often, but then I realized that
the cases where I would do that, the target would be an upvalue or a
local — if it is a global, it is likely to be a typo.

Yes! Give us that error
I do have cases where there are correct assignments of nil to table entries (to allow optional parameters to functions with named arguments), but I think it is worth a try.  I would gladly adapt the code to t[k] = optional or nil (or an if-then if necessary).

Give us that error!

Regards,
Tomás