Here args is the sequence of arguments previously passed to some function intended to accept optional arguments, defs is a hash table whose keys are the names of the optional arguments, and whose values are the corresponding default values. The return value is obtained by evaluation of (fun opts)(args'), where args' is obtained from args by removing the options of the form X=>A (where X is a name of an optional argument), and opts is a hash table of the same form as defs in which the default values have been replaced by the user-supplied values, e.g., the value stored under the key X has been replaced by A.
In the following example we use a simple definition for fun so we can see everything that fun receives from processArgs.
i1 : defs = new OptionTable from {a=>1, b=>2} |
i2 : fun = opts -> args -> {opts, args} |
i3 : processArgs(x,defs,fun) |
i4 : processArgs((x,y,b=>66),defs,fun) |
i5 : processArgs((t,u,a=>44,b=>77),defs,fun) |
See also making new functions with optional arguments, OptionTable, Option, and =>.