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

2006-09-15 Thread Peter Dalgaard
Duncan Murdoch <[EMAIL PROTECTED]> 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

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

2006-09-14 Thread Duncan Murdoch
On 9/14/2006 3:49 PM, Robert Gentleman wrote: > > Duncan Murdoch wrote: >> On 9/14/2006 3:01 PM, Seth Falcon wrote: >>> Hi, >>> >>> Can someone help me understand why >>> >>> substitute(function(a) a + 1, list(a=quote(foo))) >>> >>> gives >>> >>> function(a) foo + 1 >>> >>> and not >>> >>> f

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

2006-09-14 Thread Bill Dunlap
On Thu, 14 Sep 2006, Robert Gentleman wrote: > > > substitute(c( a = 1, b = a), list(a = quote(foo))) > > c(a = 1, b = foo) > > > > The "a" in function(a) is the name of the arg, it's not the arg itself > > yes, but the logic seems to be broken. In Seth's case there seems to be > no way to use su

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

2006-09-14 Thread Robert Gentleman
Duncan Murdoch wrote: > On 9/14/2006 3:01 PM, Seth Falcon wrote: >> Hi, >> >> Can someone help me understand why >> >> substitute(function(a) a + 1, list(a=quote(foo))) >> >> gives >> >> function(a) foo + 1 >> >> and not >> >> function(foo) foo + 1 >> >> The man page leads me to believe thi

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

2006-09-14 Thread Bill Dunlap
On Thu, 14 Sep 2006, Duncan Murdoch wrote: > I think it's the same reason that this happens: > > > substitute(c( a = 1, b = a), list(a = quote(foo))) > c(a = 1, b = foo) > > The "a" in function(a) is the name of the arg, it's not the arg itself > (which is missing). Now a harder question to answ

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

2006-09-14 Thread Duncan Murdoch
On 9/14/2006 3:01 PM, Seth Falcon wrote: > Hi, > > Can someone help me understand why > > substitute(function(a) a + 1, list(a=quote(foo))) > > gives > > function(a) foo + 1 > > and not > > function(foo) foo + 1 > > The man page leads me to believe this is related to lazy evaluation of

[Rd] Question about substitute() and function def

2006-09-14 Thread Seth Falcon
Hi, Can someone help me understand why substitute(function(a) a + 1, list(a=quote(foo))) gives function(a) foo + 1 and not function(foo) foo + 1 The man page leads me to believe this is related to lazy evaluation of function arguments, but I'm not getting the big picture. Thanks, + s