Message-ID: <BANLkTikO8hOF3utfxPLipDb6yMOygmCFAA@mail.gmail.com>
Date: 2011-04-09T19:27:35Z
From: Barry Rowlingson
Subject: best practice(s) for retrieving a local variable from a closure
In-Reply-To: <4DA09760.4020002@gmail.com>
On Sat, Apr 9, 2011 at 6:29 PM, Benjamin Tyner <btyner at gmail.com> wrote:
>> The above feels a bit like snooping where I wasn't invited.
>> You could do something like
>> ?mq <- function(a) {
>> ? ? force(a)
>> ? ? list(getA = function()a,
>> ? ? ? ? ?setA = function(newA) a <<- newA,
>> ? ? ? ? ?fun = function(x)x^a
>> ? ? )
>> ?}
>> to make it clear that you expect people to look at or change
>> fun's 'a'.
Once you start doing a lot of that though you may as well go the
whole OO hog and use the proto or R.oo packages...
Barry