lua-users home
lua-l archive

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


Hi,

RLake@oxfam.org.uk wrote:
> 
>[...] but that luaV_gettable would go into an endless loop.

The same happens if the tag method is a table and points to itself
(i.e. x=sometable eventtable(x,{gettable=x})).

> Obscure though that scenario might be, it does not strike me off-hand as
> completely unreasonable: if the "call" tag method exists to allow me to
> make userdata look like functions, it should be allowed to work
> consistently.

I make use of this for coroutines.  A coroutine is a userdata object
and calling it switches to that coroutine.

IMHO, one should remove as much checks for functions as possible and
simply assume that one _can_ call the objects.  I.e. in the luaV_gettable
case, the check "if (ttype(tm) == LUA_TFUNCTION)" should better be
"if (ttype(tm) != LUA_TTABLE)".

Btw, same thing i.e. in luaD_precall.  Why does the call tag method has
to be a function?  Or foreach, sort, gsub, ...?

Ciao, ET.