lua-users home
lua-l archive

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


2014-03-25 7:38 GMT+02:00 Coroutines <coroutines@gmail.com>:

> This led me to think maybe it would be
> useful if you could set a marker before and after a section of code
> where between which no metamethods will be called.  Rather than have
> rawget/rawset() you'd have something like:
>
> meta:no
>   local t = whatever.index
>   t()
> meta:yes
>
> Disregard the odd syntax, but the idea (I think) is an interesting one
> -- rather than having an expanding set of raw*() functions.

I like the idea of switching metamethods off and on — but dynamically,
not lexically scoped. Via routines in the debug library.

It could operate via a mask with a bit for each metamethod,
so one could switch only certain metamethods on/off.
The mask would be interrogated only when a metamethod is
about to be called, so there would not be any overhead for
programs that do not use metamethods.

It might be possible to implement it almost painlessly via tag
methods (ltm.h/ltm.c).