On Mon, Feb 4, 2019 at 5:26 PM Eran Rosenthal <eranroz89(a)gmail.com> wrote:
What is the
problem with the ".ext" part?
1. It adds unnecessary complexity both in
the extension (need to init
mw.ext if it doesn't exist)
It's one line in the boilerplate. That's not much complexity.
and more important - in its usage when the Lua
extension is invoked (longer names)
It's 4 characters. Also not much to be concerned about. You're also free to
local foo = mw.ext.foo;
if you want shorter access within your code.
(there is very small risk of name collision -
mw.ModuleA and mw.ModuleB
are unlikely to clash as different extensions, and mw.ModuleA and mw.FUNC
are unlikely to clash because function names
are usually verbs and extensions
<https://www.mediawiki.org/wiki/Category:All_extensions> are usually
Scribunto has its own built-in packages too, which are also usually nouns.
What if, for example, Extension:Math
<https://www.mediawiki.org/wiki/Extension:Math> added a Scribunto module at
"mw.math" and then we also wanted to add a Scribunto-specific version of
Or Extension:CSS <https://www.mediawiki.org/wiki/Extension:CSS> and a
Scribunto counterpart to mw.html
Or if Extension:UserFunctions
<https://www.mediawiki.org/wiki/Extension:UserFunctions> did its thing at
"mw.user" and then we got around to resolving T85419
Having mw.ext also makes it easier to identify extensions' additions,
avoiding confusion over whether "mw.foo" is part of Scribunto or comes from
another extension. And it means you can look in mw.ext to see which
extensions' additions are available rather than having to filter them out
BTW, we have "mw" in the first place to similarly bundle Scribunto's
additions away from things that come with standard Lua. If someday standard
Lua includes its own "ustring" or something else Scribunto adds a module
for (and we upgrade from Lua 5.1), we won't need to worry about name
collision there either.
2. Practically the convention is to not use mw.ext -
the convention (based
on most of the Lua code - e.g wikibase) is to not use mw.ext
Of extensions in Gerrit (as of a few days ago when I last checked),
Wikibase and LinkedWiki seem to be the only two extensions not using
mw.ext, while Cargo, DataTable2, DisplayTitle, DynamicPageListEngine,
FlaggedRevs, JsonConfig, ParserFunctions, and TitleBlacklist all do.
Brad Jorsch (Anomie)
Senior Software Engineer