Hi. I'm pretty new to R, but I've been programming in other languages for some time. I have a couple of questions regarding programming with function objects. 1. Is there a way for a function to refer generically to all its actual arguments as a list? I'm thinking of something like the @_ array in Perl or the arguments variable in JavaScript. (By "actual" I mean the ones that were actually passed, as opposed to its formal arguments, as returned by formals()).
2. I have a package in which most of the functions have the form: the.function <- function(some, list, of, params) { return( some.other.function(the.list.of.params.to.this.function)); } Is there a way that I can use a loop to define all these functions? In general, I'm looking for all the information I can find on the subject of dynamic function definition (i.e. using code to automate the definition of functions at runtime). I'm most interested in introspection facilities and dynamic code generation. E.g. is it possible to write a module that "redefines itself" when sourced? Or can a function redefine itself when first run? Or how can a function find out about how it was called? FWIW, Some of the things I'd like to do are in the spirit of a decorator in Python, which is a function that take a function f an argument and return another function g that is somehow based on f. For example, this makes it very easy to write functions as wrappers to other simpler functions. TIA! KJ [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel