lua-users home
lua-l archive

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




On 2019-06-15 8:20 p.m., Aaron B. wrote:
On Sat, 15 Jun 2019 21:50:41 +0200
Francisco Olarte <folarte@peoplecall.com> wrote:

> So, is there any problem with storing strange things in an object metatable?

My database library SqlTable does exactly this, to prevent it's
internal state information from colliding with the keys of data within
the database.

It hasn't caused problems in Lua 5.1 through to 5.3, so it at least
works well. If it's actually a good idea... I don't know.


I use

local KEY = {}
local foo = {[KEY] = {stuff}, your, data, here}

this will never conflict with something like a database. it also avoids going through a function call to do a metatable lookup and stuff. but it does get in the way of pairs, so if pairs is important for you then I guess you can't use it.