[Rd] predict.smooth.spline.fit and Recall() (Was: Re: Return function from function and Recall())
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Apr 5 18:24:28 CEST 2006
On Wed, 5 Apr 2006, Luke Tierney wrote:
> On Wed, 5 Apr 2006, Prof Brian Ripley wrote:
>
>> [...]
>>
>> Now, I was a little surprised that Recall() needed to do a lookup, but R's
>> context only contains the name of the called function and not (a pointer
>> to) the function.
>
> I think the callfun field in the context is intended to contains this
> and was added with the intent of making things like sys.function more
> reliable but I'm not sure this was ever fully implemented. Might be
> worth checking into after 2.3 and modifying Recall to use it.
What 'callfun' field? It is not documented at the top of context.c ...
silly me, believing the documentation! (Actually, the comment is quite
economical about what is there.)
It does seem applyClosure and R_execClosure set it, so this is worth
doing. What's in callfun in other contexts seems odd (and R_GlobalEnv
seems definitely wrong). tryDispatch has
begincontext(&cntxt, CTXT_RETURN, call, rho, rho, pargs,
R_NilValue);/**** FIXME: put in op */
and there are some in the byte-code section. So it is probably safe to
use callfun unless it is R_NilValue and otherwise search.
As is, we have rather inconsistent behaviour. E.g.,
library(MASS)
denumerate(~(1+2+3)^3 + a/b)
works fine, as the denumerate methods are exported. However, in a new
session do
> MASS:::denumerate(~(1+2+3)^3 + a/b)
Error in Recall(x[[2]]) : couldn't find function "denumerate.formula"
whereas MASS:::denumerate.formula(~(1+2+3)^3 + a/b) works. (Why? The
docs were wrong, and in that case the context contains the expression
needed to get the function, not the name.)
Thanks for the hint. Recall is used rarely, and it has been going wrong
in quite a few cases (apart from Henrik's and that above I managed to
generate examples in cophenetic.dendrogram and window.default), so I do
wonder if we should not be fixing this for 2.3.0.
Brian
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list