[Rd] Getting ... without evaluating it?

2005-05-19 Thread Duncan Murdoch
I'd like a function to get an unevaluated copy of its argument list, 
including ... .  That is, I'd like

f - function(...) {
  args - what goes here??
  args
}
when called as
f(a = 1+1, b = foo)
to return something like list(a = quote(1+1), b = quote(foo)).  If I use 
args - list(...) then it tries to evaluate the arguments and dies 
(because foo doesn't exist).  If I use args - substitute(...) then it 
gives just 1+1, it doesn't keep the names or give the whole list.

Is this possible?
Duncan Murdoch
__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Getting ... without evaluating it?

2005-05-19 Thread Prof Brian Ripley
On Thu, 19 May 2005, Duncan Murdoch wrote:
I'd like a function to get an unevaluated copy of its argument list, 
including ... .  That is, I'd like

f - function(...) {
 args - what goes here??
 args
}
when called as
f(a = 1+1, b = foo)
to return something like list(a = quote(1+1), b = quote(foo)).  If I use args 
- list(...) then it tries to evaluate the arguments and dies (because foo 
doesn't exist).  If I use args - substitute(...) then it gives just 1+1, it 
doesn't keep the names or give the whole list.

f - function(...) as.list(match.call())[-1]
f(a = 1+1, b = foo)
$a
1 + 1
$b
foo
(which is what list(a = quote(1+1), b = quote(foo)) prints as).
--
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595
__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Getting ... without evaluating it?

2005-05-19 Thread Duncan Murdoch
Prof Brian Ripley wrote:
On Thu, 19 May 2005, Duncan Murdoch wrote:

I'd like a function to get an unevaluated copy of its argument list, 
including ... .  That is, I'd like

f - function(...) {
args - what goes here??
args
}
when called as
f(a = 1+1, b = foo)
to return something like list(a = quote(1+1), b = quote(foo)).  If I use args 
- list(...) then it tries to evaluate the arguments and dies (because foo 
doesn't exist).  If I use args - substitute(...) then it gives just 1+1, it 
doesn't keep the names or give the whole list.

f - function(...) as.list(match.call())[-1]
f(a = 1+1, b = foo)
$a
1 + 1
$b
foo
(which is what list(a = quote(1+1), b = quote(foo)) prints as).
Thanks!
Duncan Murdoch
__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel