From p.dalgaard at biostat.ku.dk  Fri Oct  8 15:10:41 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Fri Oct  8 15:13:16 2004
Subject: [Rd] R-2.0.0  findVar and findFun question
In-Reply-To: <41667851.7020806@fri.uni-lj.si>
References: <41667851.7020806@fri.uni-lj.si>
Message-ID: <x2655ljqy6.fsf@biostat.ku.dk>

Matjaz Kukar <matjaz.kukar@fri.uni-lj.si> writes:


> My workaround for now is as follows:
> 
>     fun = Rf_findVar(Rf_install(ident), R_GlobalEnv);
>     if (fun != R_UnboundValue) {
>         fun = Rf_findFun(Rf_install(ident), R_GlobalEnv);
>         R_tryEval(fun, ...);
>     }
> 
> I did some checking on the R object pointers and indeed for generic functions
> Rf_findFun and Rf_findVar return different pointers (and therefore different
> function objects).
> 
> What has changed with these functions? Can you comment on my workaround
> and suggest a better (proper?) way of doing this?

Can't see anything relevant changed recently...

I can see that findFun gives an error if the function is not found,
which I presume is what you call a "crash". 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.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] R-2.0.0 findVar and findFun question
Peter Dalgaard