lua-users home
lua-l archive

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


joao> setmetatable(t,{__index = function(t,k) error('key is absent') end})

If only there would be a possiblity to apply it to all tables, even
the ones that have a metatable already set. And if the test in
conditions unsure if the key exists would look nicer than
rawget(t, k) ]

joao> Unintended deletions are harder, but it's part of the contract that
joao> the 'client' checks if the value (or the key) is nil. Frankly I'd
joao> prefer if t[nil] was a noop, for consistency.

I understand your logic, but IMHO it would only push  error raising
further down the drain from where an error occured.