processArgs
processArgs(args,defaults,function)
-- Here args
is the sequence of arguments previously passed to some function
intended to accept optional arguments, defaults
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
function(newargs,options)
,
where newargs is obtained from args by removing the
options of the form X=>A
(where X
is a
name of an optional argument), and options
is a hash table
of the same form as defaults
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
. As shorthand for the option X=>true
the
one may use X
.
i1 = processArgs((t,u,a=>4,c), new HashTable from {a=>1,b=>2,c=>false},identity)
o1 = (t,u,c),OptionTable{a => 4 }
b => 2
c => false
o1 : Sequence
See also OptionTable, Option, and =>.
Go to main index.
Go to concepts index.