At the Extension:Scribunto/Lua reference manual, at several places,[1] it is pointed out that the lua-libs should use the form 'mw.ext.NAME'. This creates visual noise in the code. Any lib included should have a extension page, thus it has already been given an unique name. In addition, only the libraries that need to be preloaded are added to the mw-structure, and those are the extensions. The ext-addition is like saying "this is an extension and it is only extensions that needs to be added to the mw-struct so we make it abundantly clear that this is an extension".
The only cases where a name can collide is if some external lib is included, that external lib has the same name as an extension, and if someone in addition preloads the external lib. The chance is quite frankly pretty slim, as there are rather few external libs that makes sense to preload in this environment, especially as preloading imply some kind of interaction with the environment. That means it is an extension.
I guess I'm stepping on some toes here…
So to make it abundantly clear, not 'mw.ext.NAME' (or 'mw.ext.NaMe', or 'mw.ext.name') but 'mw.name' (lowercase, not camelcase). If the call is a constructor or some kind of builder interface, then 'mw.name(…)' is totally valid. I do not believe it is wise to turn the lib into an instance by the call, but it can return an instance, it can cache previously returned instances, and it can somehow install the instance(s) in the current environment.
An extension should have any pure root libs at 'pure/name.lua' and additional libs at 'pure/name/additional.lua', where 'pure' is resolved in the 'ScribuntoExternalLibraries' hook.
[1] https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Exte...)
Is there a question assigned with this long email? Is this a call for feedback?
Kind regards Thiemo
It is a description of how it should be done, which is not according to the current page. Yes it is a call for feedback if I must spell it out.
On Fri, Jan 25, 2019 at 8:33 AM Thiemo Kreuz thiemo.kreuz@wikimedia.de wrote:
Is there a question assigned with this long email? Is this a call for feedback?
Kind regards Thiemo
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
"How it should be done" according to whom? This might be a dumb question, but I had the impression you are speaking for a larger group of people in your initial post. I would like to understand the context better in which the proposed standard came to be.
Personally, I don't support the idea of an open-for-everything "mw.randomStuff" naming scheme. It's half a century that I'm actively working with code that contains the sequence "mw." literally thousands of times: https://codesearch.wmflabs.org/search/?q=%5Cbmw%5C.%5Cb. After all these years my expectation is that stuff is only put directly in the "mw." namespace when it is general purpose utility stuff. And people are even trying to reduce this.
I understand that "mw.ext." is not terribly different from using "mw." directly. Both are places for all kinds of unrelated random stuff. But I believe it is still useful to have both: "mw." exclusively for random stuff that is part of MediaWiki itself, and a different one for community code.
Kind regards Thiemo
Half a century? 50 years? You have been working for WMDE since 2014. Perhaps it would be an idea to discuss the naming scheme instead of doing questionable call to authority?
The interesting point is _what_ to gain by adding unrelated character sequences to names. If some character sequence don't convey any meaningful or important information, then don't add it. It is only adding noise. You use naming schemes to avoid name clashes, but if the context has some inherent properties that block name clashes, then don't add some random character sequences to minimize a chance for name clash that is already zero.
What extension could a preloaded library possibly clash with? Such an extension must be written for Mediawiki, and included in Scribunto, without having an extension page at mediaiwki.org. Maintained outside Phabricator/Gerrit, yes, but without an extension page? Does that even make sense?
I make up my own mind, and if I wanted to quote somebody else I would have done so.
On Fri, Jan 25, 2019 at 2:39 PM Thiemo Kreuz thiemo.kreuz@wikimedia.de wrote:
"How it should be done" according to whom? This might be a dumb question, but I had the impression you are speaking for a larger group of people in your initial post. I would like to understand the context better in which the proposed standard came to be.
Personally, I don't support the idea of an open-for-everything "mw.randomStuff" naming scheme. It's half a century that I'm actively working with code that contains the sequence "mw." literally thousands of times: https://codesearch.wmflabs.org/search/?q=%5Cbmw%5C.%5Cb. After all these years my expectation is that stuff is only put directly in the "mw." namespace when it is general purpose utility stuff. And people are even trying to reduce this.
I understand that "mw.ext." is not terribly different from using "mw." directly. Both are places for all kinds of unrelated random stuff. But I believe it is still useful to have both: "mw." exclusively for random stuff that is part of MediaWiki itself, and a different one for community code.
Kind regards Thiemo
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
I meant half a decade. Thanks for assuming good faith.
You use naming schemes to avoid name clashes […]
This is by far not the only reason to have a naming scheme. Probably the least interesting one.
I don't think it makes sense for me to continue contributing to this conversation, since the proposal we are discussing appears to be based on that argument alone.
Kind regards Thiemo
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
Hi,
On 1/24/19 11:33 PM, Thiemo Kreuz wrote:
Is there a question assigned with this long email? Is this a call for feedback?
I think this is probably related to/coming from https://phabricator.wikimedia.org/T107119#4894324.
- -- Legoktm
There are several extensions that diverge on the naming scheme. Some of them even being referenced as using the scheme, while not providing lua libs at all. It is a bit weird.
On Fri, Jan 25, 2019 at 7:09 PM Kunal Mehta legoktm@member.fsf.org wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
Hi,
On 1/24/19 11:33 PM, Thiemo Kreuz wrote:
Is there a question assigned with this long email? Is this a call for feedback?
I think this is probably related to/coming from https://phabricator.wikimedia.org/T107119#4894324.
- -- Legoktm
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEE2MtZ8F27ngU4xIGd8QX4EBsFJpsFAlxLUJcACgkQ8QX4EBsF JpuIGRAAtHXuDQqmJK+fqKiMYrzRE7aXkX/pis7z7F5nncPWfHpaMFKFMHeAu4/d PHvpJqifXi5LwCV/YSAugmZJaQ1FFn2u+/ZA9sXAAR0JBvHnY/A5unmfXkzpteEP eUSCtexL5vjyjVo+Yd/ixbg06FS9Jc/6dxECxb6/A84gjHHQxA9drK4bkLZRvGPj 2oInMsB37iBj5/Q/ShO8Km2hz7HJ/zNyW5ljFTYwTKzNiPBcGdswMLu4vj0ALfIF OHwUeHj+M6i5UqnP0HiRBSHeFWo9it6RSXEd+lfVNbn46VJZ3zkNUFDqkWeJOWgs o3N781lCdRbcn/P3V+k2CkQhVqjGPb/MgxUyQAreup8fcwBcDiDkj7wNnnUETVuS EYg3Fc/xlrjIKYO54LSU5kHphEhCxAHdbxol8X8mNPQ3IHGQpyJCCSX6+qSGM/0+ CYtNh+ktJSyghmdUv2QOvjSkObTKL2HV9yLD3a/3qqO+Pekn9mnoNax/Splr0bV2 OkK9KMBEd73+/r+6hmhQoJdESOjLofyzoT9ohR3xWlJSfH8XOAWkphbuu87Dp0k1 KNjue1eP0KY5bO4+64hnqbCpeVpJiaQjkw+uCTmLz7u7tBME1rt7D+3D0PizXENN NNkLc4XNl4ouKti3Yhkx0P4TAy/QIDR15M0eSSikHJI8PehqnRU= =V+xr -----END PGP SIGNATURE-----
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
I agree with John, and I think mw.ext.EXTNAME should be avoided and we should prefer mw.EXTNAME which is clear and simple and fills very native. This is already the way it is used in wikibase (mw.wikibase.FUNCNAME) which I believe is the most heavily used extension exposing Lua interface.
To conclude: 1. We should either accept this convention (dropping the "ext") and update https://www.mediawiki.org/wiki/Extension:Scribunto/Example_extension 2. or we should reject this proposal and open phab ticket to wikibase to change mw.wikibase to mw.ext.wikibase everywhere (probably keeping the first for backward compatibility)
Thanks, Eran
On Fri, Jan 25, 2019 at 9:48 PM John Erling Blad jeblad@gmail.com wrote:
There are several extensions that diverge on the naming scheme. Some of them even being referenced as using the scheme, while not providing lua libs at all. It is a bit weird.
On Fri, Jan 25, 2019 at 7:09 PM Kunal Mehta legoktm@member.fsf.org wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
Hi,
On 1/24/19 11:33 PM, Thiemo Kreuz wrote:
Is there a question assigned with this long email? Is this a call for feedback?
I think this is probably related to/coming from https://phabricator.wikimedia.org/T107119#4894324.
- -- Legoktm
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEE2MtZ8F27ngU4xIGd8QX4EBsFJpsFAlxLUJcACgkQ8QX4EBsF JpuIGRAAtHXuDQqmJK+fqKiMYrzRE7aXkX/pis7z7F5nncPWfHpaMFKFMHeAu4/d PHvpJqifXi5LwCV/YSAugmZJaQ1FFn2u+/ZA9sXAAR0JBvHnY/A5unmfXkzpteEP eUSCtexL5vjyjVo+Yd/ixbg06FS9Jc/6dxECxb6/A84gjHHQxA9drK4bkLZRvGPj 2oInMsB37iBj5/Q/ShO8Km2hz7HJ/zNyW5ljFTYwTKzNiPBcGdswMLu4vj0ALfIF OHwUeHj+M6i5UqnP0HiRBSHeFWo9it6RSXEd+lfVNbn46VJZ3zkNUFDqkWeJOWgs o3N781lCdRbcn/P3V+k2CkQhVqjGPb/MgxUyQAreup8fcwBcDiDkj7wNnnUETVuS EYg3Fc/xlrjIKYO54LSU5kHphEhCxAHdbxol8X8mNPQ3IHGQpyJCCSX6+qSGM/0+ CYtNh+ktJSyghmdUv2QOvjSkObTKL2HV9yLD3a/3qqO+Pekn9mnoNax/Splr0bV2 OkK9KMBEd73+/r+6hmhQoJdESOjLofyzoT9ohR3xWlJSfH8XOAWkphbuu87Dp0k1 KNjue1eP0KY5bO4+64hnqbCpeVpJiaQjkw+uCTmLz7u7tBME1rt7D+3D0PizXENN NNkLc4XNl4ouKti3Yhkx0P4TAy/QIDR15M0eSSikHJI8PehqnRU= =V+xr -----END PGP SIGNATURE-----
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Sound proposal in my opinion.
Greg Rundlett https://eQuality-Tech.com https://freephile.org
On Sat, Feb 2, 2019 at 8:32 AM Eran Rosenthal eranroz89@gmail.com wrote:
I agree with John, and I think mw.ext.EXTNAME should be avoided and we should prefer mw.EXTNAME which is clear and simple and fills very native. This is already the way it is used in wikibase (mw.wikibase.FUNCNAME) which I believe is the most heavily used extension exposing Lua interface.
To conclude:
- We should either accept this convention (dropping the "ext") and update
https://www.mediawiki.org/wiki/Extension:Scribunto/Example_extension 2. or we should reject this proposal and open phab ticket to wikibase to change mw.wikibase to mw.ext.wikibase everywhere (probably keeping the first for backward compatibility)
Thanks, Eran
On Fri, Jan 25, 2019 at 9:48 PM John Erling Blad jeblad@gmail.com wrote:
There are several extensions that diverge on the naming scheme. Some of them even being referenced as using the scheme, while not providing lua libs at all. It is a bit weird.
On Fri, Jan 25, 2019 at 7:09 PM Kunal Mehta legoktm@member.fsf.org wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
Hi,
On 1/24/19 11:33 PM, Thiemo Kreuz wrote:
Is there a question assigned with this long email? Is this a call for feedback?
I think this is probably related to/coming from https://phabricator.wikimedia.org/T107119#4894324.
- -- Legoktm
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEE2MtZ8F27ngU4xIGd8QX4EBsFJpsFAlxLUJcACgkQ8QX4EBsF JpuIGRAAtHXuDQqmJK+fqKiMYrzRE7aXkX/pis7z7F5nncPWfHpaMFKFMHeAu4/d PHvpJqifXi5LwCV/YSAugmZJaQ1FFn2u+/ZA9sXAAR0JBvHnY/A5unmfXkzpteEP eUSCtexL5vjyjVo+Yd/ixbg06FS9Jc/6dxECxb6/A84gjHHQxA9drK4bkLZRvGPj 2oInMsB37iBj5/Q/ShO8Km2hz7HJ/zNyW5ljFTYwTKzNiPBcGdswMLu4vj0ALfIF OHwUeHj+M6i5UqnP0HiRBSHeFWo9it6RSXEd+lfVNbn46VJZ3zkNUFDqkWeJOWgs o3N781lCdRbcn/P3V+k2CkQhVqjGPb/MgxUyQAreup8fcwBcDiDkj7wNnnUETVuS EYg3Fc/xlrjIKYO54LSU5kHphEhCxAHdbxol8X8mNPQ3IHGQpyJCCSX6+qSGM/0+ CYtNh+ktJSyghmdUv2QOvjSkObTKL2HV9yLD3a/3qqO+Pekn9mnoNax/Splr0bV2 OkK9KMBEd73+/r+6hmhQoJdESOjLofyzoT9ohR3xWlJSfH8XOAWkphbuu87Dp0k1 KNjue1eP0KY5bO4+64hnqbCpeVpJiaQjkw+uCTmLz7u7tBME1rt7D+3D0PizXENN NNkLc4XNl4ouKti3Yhkx0P4TAy/QIDR15M0eSSikHJI8PehqnRU= =V+xr -----END PGP SIGNATURE-----
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
[…] I think mw.ext.EXTNAME should be avoided […]
Can I ask to provide arguments that help others understand this opinion better? What is the problem with the ".ext" part?
[…] or we should reject this proposal and open phab ticket to wikibase to change mw.wikibase to mw.ext.wikibase everywhere […]
How is this an unavoidable consequence of deciding on a standard new code should follow? What is the benefit of moving existing code that is so heavily used?
Kind regards Thiemo
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) and more important - in its usage when the Lua extension is invoked (longer names) (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 https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Base_functions are usually verbs and extensions https://www.mediawiki.org/wiki/Category:All_extensions are usually nouns) 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
What is the benefit of moving existing code that is so heavily used?
consistency and alignment to some code convention (2). [keeping backward compatibility can be with mw.wikibase=mw.ext.wikibase with deprecation notice] If we believe ext is good convention we should drive to align it and at least to allow usages https://www.google.com/search?domains=wikipedia.org&q=site%3Awikipedia.org+"mw.wikibase" to align to that convention. (google counts 3K usages - if we don't fix it, it will be much harder to fix it later) if we don't believe this is good convention, we shouldn't impose it on new Lua extensions.
Thanks, Eran
On Mon, Feb 4, 2019 at 4:13 PM Thiemo Kreuz thiemo.kreuz@wikimedia.de wrote:
[…] I think mw.ext.EXTNAME should be avoided […]
Can I ask to provide arguments that help others understand this opinion better? What is the problem with the ".ext" part?
[…] or we should reject this proposal and open phab ticket to wikibase
to change mw.wikibase to mw.ext.wikibase everywhere […]
How is this an unavoidable consequence of deciding on a standard new code should follow? What is the benefit of moving existing code that is so heavily used?
Kind regards Thiemo
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On Mon, Feb 4, 2019 at 5:26 PM Eran Rosenthal eranroz89@gmail.com wrote:
What is the problem with the ".ext" part?
- 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 do like
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 < https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Base...
are usually verbs and extensions https://www.mediawiki.org/wiki/Category:All_extensions are usually nouns)
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 Lua's math library https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Math_library? Or Extension:CSS https://www.mediawiki.org/wiki/Extension:CSS and a Scribunto counterpart to mw.html https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#HTML_library? 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 https://phabricator.wikimedia.org/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 of mw.
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.
- 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.
Those that break the naming scheme *somehow* is 7 extensions (ArticlePlaceholder (mixed case), DynamicPageListEngine (not extension name), JsonConfig (not extension name), LinkedWiki (not ext structure), SemanticScribunto (not extension name), Wikibase Client (not ext structure), ZeroPortal (not ext structure)) of a total of 17. I have not counted two of my own that will not follow this scheme, and Capiunto which use require. I have neither included TemplateData.
That is; the naming scheme is followed by approx 40% of the extensions.
There are probably some lua-libs I haven't found.
-- list -- # ArticlePlaceholder mw.ext.articlePlaceholder
# TitleBlacklist mw.ext.TitleBlacklist (Only a single method)
# BootstrapCompoinents mw.bootstrap.*
# Capiunto Doc says mw.capiunto, but this seems wrong
# Cargo mw.ext.cargo
# DataTable2 mw.ext.datatable2
# DisplayTitle mw.ext.displaytitle
# DynamicPageListEngine mw.ext.dpl
# FlaggedRevs mw.ext.FlaggedRevs
# Inference Under development.
# JsonConfig mw.ext.data.get
# LinkedWiki mw.linkedwiki
# ParserFunctions mw.ext.ParserFunctions (Only a single method)
# Pickle Under development. Uses another loader.
# SemanticScribunto mw.smw
# TimeConvert mw.ext.timeconvert
# TitleBlacklist mw.ext.TitleBlacklist
# VariablesLua mw.ext.VariablesLua
# Wikibase Client mw.wikibase
# ZeroPortal mw.zeroportal
On Tue, Feb 5, 2019 at 5:50 PM Brad Jorsch (Anomie) bjorsch@wikimedia.org wrote:
On Mon, Feb 4, 2019 at 5:26 PM Eran Rosenthal eranroz89@gmail.com wrote:
What is the problem with the ".ext" part?
- 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 do like
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 < https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Base...
are usually verbs and extensions https://www.mediawiki.org/wiki/Category:All_extensions are usually nouns)
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 Lua's math library https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Math_library? Or Extension:CSS https://www.mediawiki.org/wiki/Extension:CSS and a Scribunto counterpart to mw.html https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#HTML_library? 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 https://phabricator.wikimedia.org/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 of mw.
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.
- 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 Wikimedia Foundation _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org