On Tue, Sep 26, 2017 at 3:25 AM, mathieu stumpf guntz <
psychoslave(a)culture-libre.org> wrote:
So in Lua, as far as I can say, there is no way to
express directly
something like `a = {b=1, c=a.b}`.
Well, if your data is read-only you could do `a = { b = 1 }; a.c = a.b`.
Moreover, `a.c = 2` should lead to a state where `a.b
== a.c and a.b == 2`
For that you'll probably want to use a metatable[1] with __index and
__newindex methods that map them both to the same key.
I note that neither metatables nor function accessors will work for data
modules loaded with mw.loadData(), but since assignment doesn't work with
them either that doesn't really matter.
[1]:
https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Met…
--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation