On Nov 13, 2009, at 2:47 PM, Duncan Murdoch wrote:

> Inconsistent with what happens for lists:
> 
> > x <- list()
> > x$b
> NULL
> 
> and attributes:
> 
> > attr(x, "b")
> NULL

Ah, I see. I would claim that the same argument for default safety should apply 
here too.

> It is already a little stricter than $ on a list:
> 
> > x$longname <- 1
> > x$long
> [1] 1
> > e$longname <- 1
> > e$long
> NULL

I apologize that I cannot say that this is a good idea for reasons of safety 
and readability.

> so I supposed we could make it even more strict, but there is an awful lot of 
> code out there that uses tests like
> 
> if (!is.null(x <- e$b)) { do something with x }
> 
> and all of that would break.

Unfortunately, such code does make it harder to detect programming errors.
I understand should the hands of R be tied by backwards-compatability; bad 
habits are hard to break.
Thanks for your time.

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

Reply via email to