Wacek Kusnierczyk wrote:
> 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())
>
>   

though, 'of course', these two versions are not effectively equivalent; try

    g = f
    f()
    c(g, f)

with both definitions.

vQ

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to