Re: [Rd] R-2.0.0 findVar and findFun question

From: Matjaz Kukar <>
Date: Sat 09 Oct 2004 - 06:21:32 EST

Peter Dalgaard wrote:

> Can't see anything relevant changed recently...

Well, the visible change for me was that findVar now for generic functions does not return the correct object, and so findFun should be used. Although this is probably a consequence of some deeper change.

> I can see that findFun gives an error if the function is not found,
> which I presume is what you call a "crash".

Not really. On WinXP this crash was access violation in some system code.

> However, your workaround
> wouldn't catch the situation where a variable exists, but none of the
> versions in the search path are functions.
> I think you want to use findVar1() instead.

Indeed. Thank you for this tip. Although so far I didn't run into such a situation, I changed the code to the following:

// First we try to find a function with a given name

   obj = findVar1(Rf_install(ident), R_GlobalEnv, FUNSXP, TRUE); // If there is no function, anything else will do

   if (obj == R_UnboundValue)

       obj = findVar1(Rf_install(ident), R_GlobalEnv, ANYSXP, TRUE);

The resulting object is stored and later used to construct a SEXP used in R_tryEval(...). Only here an application should (and now, thanks to your advice, does) complain if there is something wrong.

I suppose, FUNSXP means functions (Rinternals says "Closure or Builtin"), and ANYSXP means anything. Should inherits (last) parameter be used as TRUE?

Could you point me to some relevant documentation concerning R API? The "standard" documentation is often not detailed enough.

All the best,


dr. Matjaz Kukar
Univerza v Ljubljani
Fakulteta za racunalnistvo in informatiko
Trzaska 25, 1001 Ljubljana

______________________________________________ mailing list
Received on Sat Oct 09 06:54:08 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:20 EST