From pgilbert at bank-banque-canada.ca  Fri Jun 30 22:19:19 2006
From: pgilbert at bank-banque-canada.ca (Paul Gilbert)
Date: Fri, 30 Jun 2006 16:19:19 -0400
Subject: [Rd] foo2Args()
Message-ID: <44A58747.7080705@bank-banque-canada.ca>

I was just considering trying to clean up the arguments to a function 
that calls other functions,
and was playin with a suggestion Achim made during a conversation at 
useR.  The idea is, instead of using list(), use a small function to 
construct and check arguments. My hope was to be able to do this without 
making it globally visible:

foo <- function(x, args=foo2Args()) {
  foo2Args <- function(a=1, b=2){list(a,b)}
  # above would actual do more testing of args
  #now I would call foo2 with args, but to test just
  args
  }
 
Now,

 > foo(1)   # should I be surprized that this works
[[1]]
[1] 1

[[2]]
[1] 2

 > foo(1, args=foo2Args(a=2, b=10)) # or that this does not
Error in foo(1, args = foo2Args(a = 2, b = 10)) :
    could not find function "foo2Args"

Paul
====================================================================================

La version fran?aise suit le texte anglais.

------------------------------------------------------------------------------------

This email may contain privileged and/or confidential inform...{{dropped}}



[Rd] foo2Args()
Paul Gilbert