|
Quoting temp212@gorodok.net:
On Thu, 29 Jun 2017 15:01:00 +0100 Javier Guerra Giraldez <javier@guerrag.com> wrote:On 29 June 2017 at 14:09, <temp212@gorodok.net> wrote:BUT, the problem is there is no way to set it as metatable to newly created tables automaticallyfunction m(t) return setmetatable(t, mathematicmetatable) end m{x,y,z} * m{1, 0, 1} + 5 -- JavierThanks Javier, this would work, but additional letter before table still looks a little bit ugly to me, although not as ugly as my patch that from internals gets the default metatable using C api.
While it might be conceived as ugly it is also explicit. This is important if you get back to your code a couple of months later and wonder why is it doing what it's doing. Or if other people try to understand your code.If you like to be more explicit you could turn the function into a object constructor using __call. -tobbik