From p.dalgaard at biostat.ku.dk  Fri Sep 15 10:05:32 2006
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: 15 Sep 2006 10:05:32 +0200
Subject: [Rd] Question about substitute() and function def
In-Reply-To: <4509E4B0.4020702@stats.uwo.ca>
References: <m2d59y8e7o.fsf@ziti.fhcrc.org> <4509AFA4.6010203@stats.uwo.ca>
	<4509B22D.1050604@fhcrc.org> <4509E4B0.4020702@stats.uwo.ca>
Message-ID: <x2venpy2pf.fsf@turmalin.kubism.ku.dk>

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




[Rd] Question about substitute() and function def
Peter Dalgaard