Summary
As a package developer, in order to verify that an argument is one of a set of expected classes, I would like to cast the argument to whichever class works.
Proposed signature
stabilize_any_of(
x,
...,
x_arg = caller_arg(x),
call = caller_env(),
x_class = object_type(x)
)
Arguments
x, x_arg, call, x_class: As in other to_*() functions.
...: Stabilizer functions (stabilize_* functions, to_* functions, or functions produced with specify_*() calls). Similar to the ... in stabilize_df() and stabilize_lst(), but they should not be named.
Details
Pass x through each member of ... in sequence. If it succeeds, use the result. If it throws an error, try the next function (if there is one), or throw an accumulated error if not. The accumulated message should combine the individual error messages. We'll need to experiment to make sure the result makes sense.
Summary
Proposed signature
Arguments
x,x_arg,call,x_class: As in otherto_*()functions....: Stabilizer functions (stabilize_*functions,to_*functions, or functions produced withspecify_*()calls). Similar to the...instabilize_df()andstabilize_lst(), but they should not be named.Details
Pass
xthrough each member of...in sequence. If it succeeds, use the result. If it throws an error, try the next function (if there is one), or throw an accumulated error if not. The accumulated message should combine the individual error messages. We'll need to experiment to make sure the result makes sense.