Feature summary:
On Wikifunctions add two programming languages: python-raw and javascript-raw. These would be duplicates of the current available languages except for the behaviour of their conversions to and from code. The new conversions would usually mimic the raw object key structure as closely as possible.
Use case(s):
There are some functions which currently cannot work with code implementations, and must be constructed from compositions. This is because the lovely converters to code we have built deliberately obscure some of the technical details of the object they are being passed, and if that technical detail is important, then it would be good to have a method to access it.
A simple example is: https://www.wikifunctions.org/view/en/Z19733 [Numerator of unsimplified rational], and anything that relies on it (because higher up code implementations can't call Z19733 as a subroutine).
An example of where we want to return an unsimplified rational is here: https://www.wikifunctions.org/view/en/Z26982 [equal rational with numerator length].
You may ask: Didn't we agree that rationals are rationals and 1/2 == 2/4? So why would we ever need the unsimplified components? One example of why: When we built the Wikidata quantity type, we used rational keys as components, but in order to preserve the implicit precision of Wikidata quantities ("0.1000" is more precise than "0.1"), we do not simplify them when passing them to code. We make use of this nearly everywhere, even in the display functions. It also allows functions like https://www.wikifunctions.org/view/en/Z28509 [convert Wikidata quantity to compatible unit] to do very fancy stuff.
You may then ask: If the rationals in Wikidata quantities are already not simplified in code conversion, why do we need *-raw anyway? The rational component keys are often passed into other functions as rationals, where the code conversion occurs.
Benefits:
- Code (especially JS) implementations are often a lot faster than compositions.
- Code conversion is sometimes a little time consuming by itself.
- Technical implementations would be more accessible. Often the current composition workarounds extend to multiple levels of composition and helper functions to ultimately call code anyway (once the technical object keys are extracted and passed down), which makes creating them extremely complicated (less than a handful of functioneers do this).
- This solution would not interfere with existing implementations, but would just allow a parallel pathway when none is currently possible.
- This solution will give us significant additional flexibility.
- This solution may even help solve the problems we have with functions that return object-typed lists (e.g. https://phabricator.wikimedia.org/T370028 https://phabricator.wikimedia.org/T359500), where the back end code can't always guess what type it is receiving back, which prohibits code implementations. If code-raw implementations were possible, that would be a huge step forward.