[Rd] [R] Semantics of sequences in R

Berwin A Turlach berwin at maths.uwa.edu.au
Mon Feb 23 04:34:22 CET 2009

G'day Stavros,

On Sun, 22 Feb 2009 16:50:13 -0500
Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> On Sun, Feb 22, 2009 at 4:12 PM, Duncan Murdoch
> <murdoch at stats.uwo.ca> wrote:


> > Which ones in particular should change?  What should they change
> > to? What will break when you do that?
> In many cases, the orthogonal design is pretty straightforward.  And
> in the cases where the operation is currently an error (e.g.
> sort(list(...))), I'd hope that wouldn't break existing code. [...]

This could actually be an example that would break a lot of existing

sort is a generic function, and for sort(list(...)) to work, it would
have to dispatch to a function called sort.list; and as Patrick Burns'
"The R Inferno" points out, such a function exists already and it is not
for sorting list.  

In fact, currently you get:

R> cc <- list(a=runif(4), b=rnorm(6))
R> sort(cc)
Error in sort.list(cc) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

Thus, to make sort(list()) work, you would have to rename the existing
sort.list and then change every call to that function to the new name.
I guess this might break quite a few packages on CRAN.


=========================== Full address =============================
Berwin A Turlach                            Tel.: +65 6516 4416 (secr)
Dept of Statistics and Applied Probability        +65 6516 6650 (self)
Faculty of Science                          FAX : +65 6872 3919       
National University of Singapore     
6 Science Drive 2, Blk S16, Level 7          e-mail: statba at nus.edu.sg
Singapore 117546                    http://www.stat.nus.edu.sg/~statba

More information about the R-devel mailing list