analyze_three_dots {lazy.tools}R Documentation

Analyze Three Dots and Return the Names and the Values

Description

Analyze Three Dots and Return the Names and the Values

Usage

analyze_three_dots(..., omit_NULL = 1, print_the_result = 0, debug_Debug = 0)

Arguments

...

The three dots to be analyzed.

omit_NULL

= 0 to include the NULL arguments.

print_the_result

= 1 to print the result

debug_Debug

= 1 to print intermediate info

Details

... will be analyzed and the pair of ( name, val ) and name2 will be returned.
See the first example below.

Note that, when ... is used, partial match of formal and actual arguments may cause a confusing error.
See the last example below.

Value

A list of:
name A vector consisting of the names of each of ...
val A list consisting of the values of each of ... or NULL
name2 For the named arguments, name2 contains the righthand side of the equal signs which appear in ... .
For the positional arguments, name2 contains the actual argument itself.

Examples

cc="cccc"
analyze_three_dots( a=1, b=c(2,3), cc, list(aa=1,2), diag(2) )
analyze_three_dots( a=1, b=c(2,3), cc=NULL, d=0, NULL )
analyze_three_dots( a=1, b=c(2,3), cc=NULL, d=0, NULL, omit_NULL=0 )

# a function to print all of ... with names
mprint <- function( ... ){
 atd=analyze_three_dots( ... )
 for( i in 1:length(atd$name) ){
  cat(atd$name[i], ":", atd$name2[i],"\n")
  print(atd$val[[i]])
 }
}
mprint( 1:5, b=7:11 )
#'
# About partial match of the arguments
# "e" will be missing
test <- function( exp, ..., debug_Debug=0 ){
	res=analyze_three_dots( ..., debug_Debug=debug_Debug  )
	Print(res)
}
expr="aaa"
test( expr, a=1, b=2, c=3, d=4, e=5, f=6, g=7 )




[Package lazy.tools version 0.1.6 ]