|
On 03-Oct-22 19:35, Francisco Olarte wrote:
If you just want that effect you can ommit the intermediate stuff of building a callable object and just return a closure capturing the key ( it will be slower if you call it in a loop ) ( sample stripped for brevity )function g(k, ...) print(k, ...) end f = {} setmetatable(f, { __index = function(t, k) return function(...) g(k, ...) end end, }) f.abc("Lua", "is very well designed") f.k("No longer buggy now.") <<<<<<<
Thanks, Francisco!I can probably live without the caching, or reintroduce it... correctly next time :-)
You can rely on it until lua changes its working, which it does for other things, but has not done in a way for fundamental things as this. And I suppose you'll get ample warning on this case.
Very good, thanks also to all other people that replied. -- Enrico