1 #include <R.h> 2 #include <Rinternals.h> 3 dotsElt(SEXP env_,SEXP i_)4SEXP dotsElt(SEXP env_, SEXP i_) { 5 SEXP ddd = findVar(R_DotsSymbol, env_); 6 int i = INTEGER(i_)[0]; 7 R_len_t n = length(ddd); 8 9 if (ddd == R_UnboundValue) 10 error("incorrect context: the current call has no '...' to look in"); 11 if (i <= 0) 12 error("indexing '...' with non-positive index %d", i); 13 if (i > n) 14 error("the ... list does not contain %d elements", i); 15 16 ddd = nthcdr(ddd, i - 1); 17 return eval(CAR(ddd), env_); 18 } 19