On Sat, Jun 04, 2005 at 07:08:56PM +0200, Martin Maechler wrote:
>     Ross> nextPath <- function(pm){ #pm is a CompletePathMaker
>     Ross>    [EMAIL PROTECTED] <- [EMAIL PROTECTED](1)
>     Ross> [etc]
> 
> If your nextPath   function has  'pm' as its last statement it
> will return the updated object, and if you call it
> as
>       mypm <- nextPath(mypm)
> 
> you are
>     1) updating  mypm
>     2) in a proper S way (i.e. no cheating).
> 
> Regards,
> Martin

Wow.  This is almost the exact inverse of the usual object behavior,
in which only the class itself can update the slots (aka instance
variables).  None of the methods of the class can update instances of
the class persistently without the help of outsiders, and only
outsiders can change the slot values.

(Yes, I realize that using the idiom you suggest of returning a new
object one can have only class methods actually fiddling with the
slots.)

The inability of a class method to change a class object without
outside help seems unfortunate.

It looks as if instances of class objects are best thought of as
immutable once created.

Ross

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to