[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Meta function tables for LUA_FILEHANDLE: why two separate tables?
- From: Sean Conner <sean@...>
- Date: Wed, 16 Nov 2022 04:47:58 -0500
It was thus said that the Great bil til once stated:
> ... sorry, I forgot the title in last post ... here exact copy again
> with title...
> Hi, I am just "fighting" with designing some new libs for Lua.
> I found, that liolib.c from Lua source is a very instructive lib for
> showing how to install the meta stuff, as it even includes the io lib
> together with a further metatype LUA_FILEHANDLE.
If you want to see some mor Lua libs, I have written quite a few, most are
> The function table for the file handles is strangly separated into
> "new fuctions" and "standard meta functions":
> In the function create meta, these two tables are then somehow
> combined as I see it:
> Why not use just ONE table for all meta methods, as e. g. the following table:
I'm not sure. Most of my modules mix both and set the __index field to
the metatable itself. I suppose one reason is to prevent accessing the meta
Whereas having them all in the one metatable allows one to "access" these
> pollset = require "org.conman.pollset"
> x = pollset()
and thus, they could be called from user code directly, or allow easy access
to the metatable in a sandboxed environment (i.e. no getmetatable() or