Thomas Petzoldt <[EMAIL PROTECTED]> writes:
> One odd thing I found was that initialize does obviously not allow to
> incorporate additional named parameters which are not slots.

?!  Does for me:

      setClass("FOO", representation(x="numeric"))
      [1] "FOO"
       
       setMethod("initialize", "FOO",
                 function(.Object, value) {
                     [EMAIL PROTECTED] <- value * 2
                     .Object
                 })
      [1] "initialize"

      f <- new("FOO", value=1)
      f
      An object of class "FOO"
      Slot "x":
      [1] 2

> In essence I think that one should not use the constructor approach
> (from 2001) anymore, even if the "call is independent of the details
> of the representation".

Sometimes both are useful.  You can have convenience generator
functions for users, but have initialize methods that get called
internally.  This can also be nice in that the internal code can be
lean, while common user-facing code can do lots of error and sanity
checking, etc.

+ seth

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to