foo <- function(x=NULL,y=NULL,z=2) { X <- list(x,y,z); names(X) <- names(formals()); X } z <- foo(4) z #------ $x [1] 4 $y NULL $z [1] 4