Re: [Rd] Question about substitute() and function def

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 15 Sep 2006 - 08:05:32 GMT

Duncan Murdoch <murdoch@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@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Sep 15 18:16:11 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 15 Sep 2006 - 09:30:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.