Hi,

is there an easy, robust, and/or recommended way to distinguish a missing argument from an empty argument as in:

foo <- function(i, j){
    print(missing(j))
    print(nargs())
}

foo(i)  # TRUE, 1
foo(i,) # TRUE, 2

I know I can work around with nargs, the list of arguments and the names of the passed arguments, but I wish there is something already in place for this. This is specially important for '['-like methods where x[i,] is not the same as x[i]. What I am looking for is a function that tells me if an argument has actually been passed empty:

foo <- function(i, j, k){
    print( empty.arg(j) )
    print(nargs())
}

would result in:

foo(i) # FALSE, 1
foo(i, ) # TRUE, 2
foo(i, j) # FALSE, 2
foo(i, k=2) # FALSE, 2
foo(i, k=2, ) # TRUE, 3

Thank you for any help or pointer.

Bests,
Renaud




###
UNIVERSITY OF CAPE TOWN
This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}}

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to