From murdoch.duncan at gmail.com  Tue Aug 17 12:23:08 2010
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Tue, 17 Aug 2010 06:23:08 -0400
Subject: [Rd] parent.frame(1) of a S4 method is not a calling
	environment.
In-Reply-To: <87wrrq2ns2.fsf@gmail.com>
References: <87d3tj4ku4.fsf@gmail.com> <4C698DAC.3090704@fhcrc.org>
	<87wrrq2ns2.fsf@gmail.com>
Message-ID: <4C6A630C.9020802@gmail.com>

Vitaly S. wrote:
> Martin Morgan <mtmorgan at fhcrc.org> writes:
>   
>>> So,  can I be sure that for such functions parent.frame(2) will always work?
>>> What are the additional rules?
>>>       
>> callNextMethod() will cause additional problems; the idea that you'll
>> grab things from somewhere other than function arguments doesn't seem
>> like a robust design, even if it's used in some important parts of R.
>>
>> Martin
>>
>>     
>
> That make it difficult to handle unevaluated expressions in methods. A solution
> would be to explicitly require the users to use quote() or expression(),  and
> then to use the "expression" in the signature. Slightly unpleasant, though.
>
>   

You could use formulas for that.  If you pass in

formula = ~ x + y*z

then environment(formula) will be the right evaluation environment, and 
formula[[2]] will be the unevaluated x + y*z.

Duncan Murdoch

> Standardised, simpler syntax like .() in  ggplot and plyr,  would be handy here.
> Hopefully .() is not grabbed for something else in meanwhile:).
>
> Vitaly.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] parent.frame(1) of a S4 method is not a calling environment.
Duncan Murdoch