Skip to content
Prev 36220 / 63424 Next

Strange behavior of assign in a S4 method.

Where did you get the idea that 'x' comes from the parent frame? 
There is no guarantee of this, and you are relying on/stumbling over 
implementation details here.  (An extra call is inserted by 
setMethod()  to handle the matching up of argumnets, but that is 
something which may change, and has changed in the history of the 
'methods' package.)

Note that 'x' might be an expression, even foo2(3, y=5).  You need to 
check it is a symbol.

It would seem to me to be much better to use a replacement function 
here (via setReplaceMethod in S4 land) and let the parser do most of 
the basic checking.

Incidentally, at least in modern English, an assignation is (Collins 
English Dictionary)

  	a secret or forbidden arrangement to meet

and it seems rather that you _are_ trying to do something 'secret or 
forbidden'.  (I suspect you mean 'assignment'.)
On Mon, 15 Mar 2010, Christophe Genolini wrote: