[Rd] Question about substitute() and function def
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Fri Sep 15 10:05:32 CEST 2006
Duncan Murdoch <murdoch at stats.uwo.ca> writes:
> >> > substitute(function(a=a) 1, list(a=quote(foo)))
> >> function(a = a) 1
> >
> > a bug for sure
>
> Yes.
Hmm... The issue is that the argument to `function` is a pairlist (not
LANGSXP), and we don't recurse into those. Any R object can turn up as
part of objects of mode "call" (by various methods, not least call()
constructions), and I don't think we want to substitute into any
recursive object. However, it's unlikely that pairlists would be used
for anything other than function arguments, so I suppose we could
change the behaviour (special-casing calls to `function` is an
alternative). Luke?
To wit:
> mode(quote(function(x)1)[[1]])
[1] "name"
> mode(quote(function(x)1)[[2]])
[1] "pairlist"
> mode(quote(function(x)1)[[3]])
[1] "numeric"
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-devel
mailing list