Wikifunctions:Type proposals/Named parameters list
Summary
This tipe is mainly meant to collect all the named parameters passed to the function when called from Wikitext. Currently named parameters are not supported; their support would make function calls from Wikipedia and other projects more coustomisable and in general would be a great help in facilitating the adoption of Wikifunctions on other Wikiprojects.
Uses
- When the last argument of a function is of type Named parameters list and said function is called from Wikitext, the parser should not expect to directly expect the value of this argument; instead, all the named parameters should be inserted in this last argument.
- The named parameters "renderlang" and "parselang" should always be passed to said argument, even if not explicitly indicated in the function call.
- Since all the named parameters are passed as strings, it's the function's duty to read them in the appropriated types, using the "parselang" parameter and manually calling the correct reader function.
Structure
It should only contain a key (ZnnnnK1) of type Typed list (Z881) of Typed pair (Z882) of String (Z6) and String (Z6).
Example values
Consider this function call, done in the Dagbani Wikipedia:
{{#function:Zmmmmm|a|b|c=parameter1|d=42|parselang=en}}.
If Zmmmmm only has two arguments, and the last one isn't of type Named parameters list, then the named arguments should be ignored (except parselang, that instead should affect the language used for displaying the output).
If Zmmmmm has 3 arguments, and the third one is of type Named parameters list, then the third argument should have the value:
- ZnnnnK1: List:
- Pair ("c", "parameter1")
- Pair ("d", "42")
- Pair ("renderlang", "dag")
- Pair ("parselang", "en")
The "renderlang" and the "parselang" should still be used for parsing the unnamed parameters and for rendering the output.
In all other instances, this function call is ill-formed.
Validator
The validator ensures that:
- ZnnnnK1 is a valid list of pairs of 2 strings.
Identity
Two Named parameters lists are the same if they have the same values under the same keys, in any order. Two instanced that have the same values in different order should be considered equal.
Converting to code
Python
As a dict.
JavaScript
As an Object.
Display and read function
This type shouldn't need a read or a display function. In this way, we also avoid confusion between technical functions for handling this type and Wikipedia-specific functions that instead use this type for collecting named parameters.
Alternatives
Named parameters for reading and display functions
As an additional feature, we could add named parameters specifically for reading and display functions, in order to make them more adjustable for specific needs and to uncouple those settings to the main function.
- Functions with a third argument of type Named parameters list (other than the usual 2 parameters) should be considered valid reading and diplay functions.
- For internal uses in the Wikifunctions UI, if the reading or the display function has the third parameter, it should be empty.
- When any function is called in Wikitext, all the named arguments whose name has a prefix
read:ordisplay:should be passed to the reading and display functions respectively (if the functions support named parameters), without the prefix in the name. All the other parameters should not be passed to the reading and display functions. - It's not necessary to pass the "renderlang" and the "parselang" named parameters to reandig and display functions, since the information is already provided to those functions.
Other ideas:
- The
read:prefix could be modified to specify the type(s) it should apply to, or which argument(s) it should apply to. - As an additional feature (not neccesarly available as soon as the implementation of this type), it could be possible to set the named parameters to pass to reading and display functions used for Wikifunctions UI in the user settings, as an interface coustomisation feature.
Comments
For general comments, please reply to the proposer.
Support as proposer. Dv103 (talk) 09:38, 30 July 2025 (UTC)- This doesn't appear to be a proposal for a new Type at all, but a new software feature? Maybe you should start this proposal somewhere more suited, and then move it to Phabricator? Jdforrester (WMF) (talk) 13:13, 30 July 2025 (UTC)
- I just wanted to throw there an idea to start the discussion. Where would you advice to start it? Dv103 (talk) 22:04, 30 July 2025 (UTC)
- @Dv103: Project chat? Jdforrester (WMF) (talk) 22:25, 31 July 2025 (UTC)
- I just wanted to throw there an idea to start the discussion. Where would you advice to start it? Dv103 (talk) 22:04, 30 July 2025 (UTC)