From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Wed May 20 00:03:16 2009
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Wed, 20 May 2009 00:03:16 +0200
Subject: [Rd] Qs: The list of arguments, wrapping functions...
In-Reply-To: <4A1327AE.4040000@idi.ntnu.no>
References: <c2350ba40905191322y2bffbfdu79f4cb480732252e@mail.gmail.com>
	<4A1327AE.4040000@idi.ntnu.no>
Message-ID: <4A132CA4.3020707@idi.ntnu.no>

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



[Rd] Qs: The list of arguments, wrapping functions...
Wacek Kusnierczyk