Re: [Rd] [R] Semantics of sequences in R

From: Wacek Kusnierczyk <>
Date: Mon, 23 Feb 2009 08:52:05 +0100


Berwin A Turlach wrote:
> G'day Stavros,


>> 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
> code.
> 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.

and you mean that sort.list not being applicable to lists is a) good design, and b) something that by noe means should be fixed, right?

> 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?

one of the most funny error messages you get in r. note also that, following rolf turner's lists and vectors unproven theorem, a vector can be considered a list -- hence sort.list should raise the error on any vector input, no?

> 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.

scary! it's much preferred to confuse new users.

vQ mailing list Received on Mon 23 Feb 2009 - 06:54:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 23 Feb 2009 - 10:30:45 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive