Hacker News new | ask | show | jobs
by meric 5258 days ago
In addition to everything a python class can do, you can also use setmetatable() to modify the metatable of a table at runtime. A metatable is also just a table so you don't have to assign it to designated "metatables". You can for example even set the metatable of a table to itself.

The metatable is more general and conceptually simpler. It doesn't have to be the "class" of an "object", it can implement other patterns to OO without feeling weird, because the assumption that metatable is "Object Oriented" just isn't there.

Do you have python beginners touching metaclasses? I doubt it. Do you have lua beginners touching metatables? Certainly yes.