Synopsis:
The new function g works as follows. The value of g args, say, 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.
Remark: defs can also be simply a list of options.
In the following example we use a simple definition for fun so we can see everything that fun receives.
i1 : g = {a=>1, b=>2} ==> opts -> args -> {args, opts} |
i2 : g x |
i3 : g(x,y,b=>66) |
i4 : g(t,u,a=>44,b=>77) |
See also:
Code:
-- ../../../Macaulay2/m2/option.m2:31-38 (defaults,f) -> ( args -> ( -- Common code for functions created with ==> to -- process options and arguments. f ## override (defaults,args) ) ) )