XLSForm user-defined functions

1. What is the general goal of the feature?
User can create definitions of their own functions based on the ODK form operators and functions and reuse these definitions within the same form.
This could be a new tab in the XLSForm / not sure how it would be in XML

@RafaelKluender feel free to add more :slight_smile:

2. What are some example use cases for this feature?

I want to apply the same formatting / processing on 50 different variables in the XLSForm
I want to change the way I format / process these 50 different variables in the XLSForm

As a very simple example, there are many different formulas which can be used to approximate the body surface area from the weight and height of a patient, I could store several definitions
bsa_dubois
0.007184 * pow({0}, 0.425) * pow({1}, 0.725)

bsa_mosteller

sqrt({0} * {1} / 3600)

and just call the one(s) I want as many times as needed in different calculate questions
name1 bsa_dubois(${wt1}, ${ht1})
name2 bsa_mosteller(${wt1}, ${ht1})
name3 bsa_dubois(${wt2}, ${ht2})

but obviously this could become super interesting when using boolean operators to construct much more complex functions

3. What can you contribute to making this feature a reality?

Probably nothing concrete in the coming 6 months as I have an overwhelming workload but I would be happy to contribute more afterwards.

As a workaround, I have developed for my personal use a quick dirty Python code to automate the generation of a XLSForms that meet a standardised template / specific need, with a functional description of my form, so that the objects and functions I am using are defined with Python and used to generate the corresponding string in the calculation cell of the XLSForm.