[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 25 Mar 2014 10:46:56 +0200
2014-03-25 10:10 GMT+02:00 Tim Hill <drtimhill@gmail.com>:
>On Mar 24, 2014, at 11:21 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>> I like the idea of switching metamethods off and on — but dynamically,
>> not lexically scoped. Via routines in the debug library.
>>
>
> Why the debug library? IMHO the debug library shouldn’t really be used for production code .. if it is, then it’s not really a debug library any more except in name.
Because it should be used only when debugging.
Switching metamethods on and off is a highly error-prone
activity, one that can introduce hard-to-find bugs, and In
production code, it should be done in a more visible way,
spelling out each time which metamethod is being switched
for which object.
Something like this:
do -- `metamethods` must be invisible lower down
local metamethods={}
function disable_metamethod(object,method)
-- save metamethod in `metamethods`
-- set it to nil
end
function enable_metamethod(object,method)
-- set metamethod to what was saved earlier
end
end
- References:
- [ANN] Lua 5.3.0 (work2) now available, Luiz Henrique de Figueiredo
- Re: [ANN] Lua 5.3.0 (work2) now available, Egor Skriptunoff
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available, Andrew Starks
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), katlogic
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Hisham
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Rena
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), William Ahern
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Andrew Starks
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Dirk Laurie
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Tim Hill
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Coroutines
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Dirk Laurie
- Re: [ANN] Lua 5.3.0 (work2) now available (number coercion holy crusade), Tim Hill