[Rd] incoherent treatment of NULL

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Mon Mar 23 21:27:11 CET 2009


Martin Maechler wrote:
>
>     >> more verbously,  all NULL objects in R are identical, or as the
>     >> help page says, there's only ``*The* NULL Object'' in R,
>     >> i.e., NULL cannot get any attributes.
>     >> 
>
>     WK> yes, but that's not the issue.  the issue is that names(x)<- seems to
>     WK> try to attach an attribute to NULL, while it could, in principle, do the
>     WK> same as class(x)<-, i.e., coerce x to some type (and hence attach the
>     WK> name attribute not to NULL, but to the coerced-to object).
>
> yes, it could;  but really, the  fact that  'class<-' works is
> the exception.  The other variants (with the error message) are
> the rule.
>   

ok.

> Also, note (here and further below),
> that Using   "class(.) <-  <className>"
> is an S3 idiom   and S3 classes  ``don't really exist'', 
> the "class" attribute being a useful hack,
> and many of us would rather like to work and improve working
> with S4 classes (& generics & methods) than to fiddle with  'class<-'.
>
> In S4, you'd  use  setClass(.), new(.) and  setAs(.),
> typically, for defining and changing classes of objects.
>
> But maybe I have now lead you into a direction I will later
> regret, 
> ....
> when you start telling us about the perceived inconsistencies of
> S4 classes, methods, etc.
> BTW: If you go there, please do use  R 2.9.0 (or newer)
>   

using latest r-devel for the most part.

i think you will probably not regret your words;  from what i've seen
already, s4 classes are the last thing i'd ever try to learn in r.  but
yes, there would certainly be lots of issues to complain about.  i'll
rather wait for s5.

regards,
vQ



More information about the R-devel mailing list