lua-users home
lua-l archive

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


> Just to remind you, Lua 4.0 already had support for this kind of OO
> programming with basic types. For instance,
>
>   settagmethod(tag(""), "gettable", function (a,b)
>     return getglobal('str'..b)
>   end)
>
> >   ansiStr = "Hello"
> >   print(ansiStr:lower())

now this is cool!!
and i was always thinking that this cannot be done, because the reference
manual says:

``gettable'':
called whenever Lua accesses an indexed variable. This method cannot be set
for tables with the default tag.

since i cannot set this tagmethod for "vanilla" tables, i never thought i
could set it for other "vanilla" types.

Cheers,
Peter