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

From: Berwin A Turlach <berwin_at_maths.uwa.edu.au>
Date: Mon, 23 Feb 2009 11:34:22 +0800

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

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.

Cheers,         

        Berwin


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 23 Feb 2009 - 02:37:30 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 - 08:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive