From hadley at rice.edu  Wed May  4 14:38:29 2011
From: hadley at rice.edu (Hadley Wickham)
Date: Wed, 4 May 2011 07:38:29 -0500
Subject: [Rd] Capturing the complete unevaluated expression corresponding to
 function (body + formals)
Message-ID: <BANLkTikYQ-E44a1bD3zVi75Y0cAfRooSsQ@mail.gmail.com>

Hi all,

Is there any way to capture the complete unevaluated expression
corresponding to a function?  I want the equivalent of

x <- quote(function(x) x = 3)

But captured after the function is created.  Body and formals each
captures a part, but is there a built in way to get the whole thing?

f <- function(x) x = 3
y <- call("function", formals(f), body(f), attr(f, "source"))
identical(x, y)

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



[Rd] Capturing the complete unevaluated expression corresponding to function (body + formals)
Hadley Wickham