[Rd] Qs: The list of arguments, wrapping functions...
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Wed May 20 00:03:16 CEST 2009
Wacek Kusnierczyk wrote:
> Kynn Jones wrote:
>
>
>> 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?
>>
>>
>
> another quick shot from a naive r user:
>
> f = function()
> assign(
> as.character(match.call()[[1]]),
> function() evil(),
> envir=parent.frame())
>
or maybe
f = function()
body(f) <<- expression(evil())
>
> f
> f()
> f
>
vQ
More information about the R-devel
mailing list