lua-users home
lua-l archive

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


>>>>> "Dirk" == Dirk Laurie <dirk.laurie@gmail.com> writes:

 >> Some of the base functions are essentially part of the language -
 >> especially select(), pairs(), ipairs(), type(), pcall(), error(),
 >> assert(), tonumber(), tostring(). Without at least those, writing
 >> any nontrivial code will be hard.

 Dirk> In fact, without tostring, print() does not work.
 Dirk> (Monkey-patching print by changing tostring is an amusing
 Dirk> pastime.)

In my sandbox, print() does not call _G.tostring() :-)

 Dirk> I would add the string library to "essentially part of the
 Dirk> language", but you can't hide that without invoking
 Dirk> debug.setmetatable.

If you don't call luaopen_string then the string metatable is never set
up.

In my case I have no need to hide it, but I _do_ need to protect the
metatable itself from tampering, so I do the equivalent of

  getmetatable("").__metatable = true

-- 
Andrew.