normally we define functions as
f[x_, y_, z_] := ArcSin[x^2*y/z]
however when one has many arguments (as I do) I find difficult to remember what is the meaning of the argument "number 2", that is y in the above example. Of course a ?f would do the job of refreshing my memory ... but I want to find another solution, possibly more direct.
I would like to achieve the definition of a function that evaluates independently of the order in which I give the arguments, still keeping their meaning. For this I thought to exploit the nice feature of Options patters that are non-positional.
Options[disorderedf] = {x -> 0, y -> 0, z -> 0}
disorderedf[opts : OptionsPattern[]] :=
ArcSin[OptionValue[x]^2*OptionValue[y]/OptionValue[z]]
which beautifully evaluates the same independent of the order I give the values of the three coordinates
disorderedf[x -> 1, y -> 3, z -> Pi]
ArcSin[3/π]
disorderedf[y -> 3, z -> Pi, x -> 1]
ArcSin[3/π]
First of all I would like to ask if this is reinventing the wheel because Mathematica has already some type of functionality to support this way of giving arguments.
Secondly I wanted to ask if there are suggestions to speed up or simplify this or get the same behavior with simpler and more easily extendable code. I am imagining that I might in the future add more arguments and the way I did it might not be the most economical one.