Joe Conway wrote:
Yes, if I patch RNamedCall.c with the attached (based on your function),
everything seems to work.
Sorry -- I managed to mess up that patch. This one should be better.
Joe
*** ../../../R-2.5.1/tests/Embedding/RNamedCall.c Mon Sep 4 07:21:12 2006
--- RNamedCall.c Fri Jul 6 10:19:46 2007
***************
*** 2,7 ****
--- 2,9 ----
void bar1() ;
void source(const char *name);
+ static SEXP MyfindFun(SEXP symb, SEXP envir);
+
/*
Creates and evaluates a call
to a function giving named arguments
***************
*** 51,58 ****
SEXP e;
PROTECT(e = allocVector(LANGSXP, 4));
! fun = findFun(install("foo"), R_GlobalEnv);
! if(fun == R_NilValue) {
fprintf(stderr, "No definition for function foo. Source foo.R and save the session.\n");
UNPROTECT(1);
exit(1);
--- 53,60 ----
SEXP e;
PROTECT(e = allocVector(LANGSXP, 4));
! fun = MyfindFun(install("foo"), R_GlobalEnv);
! if(fun == R_UnboundValue) {
fprintf(stderr, "No definition for function foo. Source foo.R and save the session.\n");
UNPROTECT(1);
exit(1);
***************
*** 80,82 ****
--- 82,104 ----
UNPROTECT(1);
}
+ static SEXP
+ MyfindFun(SEXP symb, SEXP envir)
+ {
+ SEXP fun;
+ SEXPTYPE t;
+ fun = findVar(symb,envir);
+ t = TYPEOF(fun);
+
+ /* eval promise if need be */
+ if (t == PROMSXP){
+ int error=1;
+ fun = R_tryEval(fun,envir,&error);
+ if (error) return R_UnboundValue;
+ t = TYPEOF(fun);
+ }
+
+ if (t == CLOSXP || t == BUILTINSXP || t == BUILTINSXP || t == SPECIALSXP)
+ return fun;
+ return R_UnboundValue;
+ }
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel