Protoypes is a good pointer. Thanks!
I didn't find any automatisms, but I can do
someTable={}
setmetatable( someTable, { __index = table} )
and I am set to do someTable:insert(), someTable:concat(), etc. Neat.
Unfortunately it is not as easy for strings. There actually is an automatism for strings
in vanilla Lua, but it is turned off in Scribunto. [1]
Stephan
[1]
https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Met…;Note:
In Lua, all strings also share a single metatable, in which __index refers to the string
table. This metatable is not accessible in Scribunto, nor is the referenced `string`
table; the string table available to modules is a copy."
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On July 17, 2018 10:43 PM, Derk-Jan Hartman <d.j.hartman+wmf_ml(a)gmail.com> wrote:
Maybe you missed that table.foo (and similarly
string.foo) is the prototype for any someTable, which thus automatically has
someTable.foo(). And that someTable:foo(args) is just syntactic sugar for someTable.foo(
someTable, args ) ?
It's one of those weird Lua quirks
DJ
On Mon, Jul 16, 2018 at 1:05 PM Stephan Gambke <s7eph4n(a)protonmail.com> wrote:
> I have been playing with Scribunto recently and the one thing that struck me as odd
was that Lua has a number of methods like table.foo or string.foo, but I did not find any
factory module leveraging these methods to provide someting more intuitive like
someTable:foo or someString:foo.
> Is it just not worth it or did I miss anything?
>
> Stephan
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
>
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l