lua-users home
lua-l archive

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


On Sun, 4 Dec 2022 at 21:50, bil til <biltil52@gmail.com> wrote:
> I just recognized one thing, which sounds slightly odd to me, but
> which I MUST do, if I want to give the Lua user full flexibility with
> the "colon syntactic sugar".
...
Given your use of luaL_Reg I assume you are building tables. Why don't
you just replace....
>     // the "lib functions" without colon notation
>     // (e. g. com.open, but also com.write( ComChannel, str) ...):
>     static const luaL_Reg comlib[] = {
>         {"open", com_open},
>         {"read", com_read},
>         {"write", com_write},
>         {"close", com_close},
>         {NULL, NULL}
>     };
with
// the "lib ONLYfunctions" without colon notation
>     static const luaL_Reg comlib[] = {
>         {"open", com_open},
>         {NULL, NULL}
>     };

And
>    //the "lib meta functions" with colon notation
with
 //the "lib meta functions" with OR WITHOUT colon notation
( same contents )

And then you just do setfuncs with the first to for the library table,
setfuncs with the last two for the metatable?

FOS