maintain: Extract, Update, and Replace Argument Lists of Memified...

Description Usage Arguments Value Warning Note Author(s) See Also Examples

Description

These functions support the use of memified functions.

Usage

1
2
3
4
5
6
arglist(f)

arglist(x) <- value

## S3 method for class 'memified'
update(object, ...)

Arguments

x, f, object

A memified function.

value

A named list of argument values to replace the existing argument list. An attempt will be made to coerce a non-list to a list. If successful, the coerced arglist will be used and a warning reporting the coercion will be issued. Otherwise an error will be thrown.

...

Tagged argument-value pairs to add to or replace existing arglist arguments.

Value

arglist() returns the existing argument list.

arglist <- value replaces the existing argument list with the (possibly coerced) new list.

update() (silently) adds additional named arguments to a function's arglist and/or changes the values of any that already exist. NULL is invisibly returned.

Warning

The update and replacement functions do not check that valid argument names are used. Invalid arguments can of course cause errors when the memified functions are subsequently invoked.

Note

“arglists”, the remembered argument lists of memified functions, consist only of values that have been explicitly specified in prior calls of the memified function, or via update or arglist <- value functionality. Hence default arguments that have not been so changed or specified will not be in the arglists. See formals or args for ways to extract/change such defaults.

Author(s)

Bert Gunter

See Also

memify

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
f.m <- memify(function(a = 0, b) sin(a+b))
f.m( b = pi/4) # uses default for a
arglist(f.m)
update(f.m, a= pi/4) ## new default for a
f.m(b = -pi/4)
arglist(f.m) <- list() ## resets arglist
f.m( b = pi/4) ## The original default of a = 0 is used

## cleanup
rm(f.m)

memify documentation built on Jan. 18, 2021, 5:08 p.m.