[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc3) now available
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Tue, 28 Jun 2011 20:32:47 +0200
On 28/06/2011 19.06, Renato Maia wrote:
On 28 Jun 2011, at 07:03, Stuart P. Bentley wrote:
It seems a bit silly to force that code to use rawget, just for the
sake of a slightly different error for a specific kind of typo.
I also found it very odd indeed. :-/
Why impose such odd behavior if it is something easily done in pure Lua
I agree. It is odd.
Moreover, string library functions are often called as methods, so typos
are catched at call site anyway.
This safety net would be useful to when trying to store away a field for
later use, like in:
local gsub = string.gub -- typo!!!
But this usage is rare, at least in my code, since string methods can be
used in OOP way, so they don't need "localization":
("mystring"):gub("my", "your") -- typo!!! error raised anyway here
It is more likely to happen for other libs, for which I use
"localization" inside modules, before "barring access" to global env:
local concat = table.conct -- typo!!! but no safety net here!
So this kind of typo prevention prevents only unlikely errors, whereas
for other libraries there is no such mechanism, where it would be more
useful (note: I'm NOT advocating adding such safety net for other libs).
I'd find more Lua-like to reinstate 5.1 behaviour (no error). At least
it is uniform. This kind of safety net seems too much hand-holding to me
(and for a very limited use case).