One way that I've found that works pretty well is to define a new UDT for options, and then provide a function that returns a reasonable set of defaults. For instance, in the case you gave, you might have something like:
newtype FunOptions = (
N : Int,
SomeOtherOption : Double[]
);
function DefaultFunOptions() : FunOptions {
return (0, [0.0]);
}
function Fun(options : FunOptions) : Double {
// do something using options::N and options::SomeOtherOption
}
This lets you call Fun
by using the w/
to provide optional arguments as you see fit:
let w = Fun(DefaultFunOptions());
let x = Fun(DefaultFunOptions() w/ N <- 10);
let y = Fun(DefaultFunOptions() w/ SomeOtherOption <- [0.1, 0.2]);
let z = Fun(DefaultFunOptions() w/ N <- 42 w/ SomeOtherOption <- [0.1, 0.2]);
This is the approach taken, for instance, with the new quantum machine learning library currently under development. If you're interested, check out the pull request where the new TrainingOptions
UDT was first introduced at https://github.com/microsoft/QuantumLibraries/pull/187.