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

From: Stavros Macrakis <macrakis_at_alum.mit.edu>
Date: Mon, 23 Feb 2009 00:21:57 -0500

On Sun, Feb 22, 2009 at 10:34 PM, Berwin A Turlach <berwin_at_maths.uwa.edu.au> wrote:
> G'day Stavros,

Hello, Berwin,

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

>> ...sort(list(...))), I'd hope that wouldn't break existing code. [...]

> ...sort is a generic function, and for sort(list(...)) to work, it would
> have to dispatch to a function called sort.list;... such a function exists
> already and it is not for sorting list.

Omigod. There is a function called 'sort' which doesn't sort, and which follows the S3 conventions for sorting lists, but doesn't allow lists as an argument type. That *is* a mess!

Well, if it's OK for sort.list to violate S3 naming conventions (presumably because it was defined before S3 was), then I suppose it would be OK for sort to violate S3 coding conventions in return, and dispatch in a non-standard way, e.g.

      if (is.list(x)) sort.S3.list(...) else UseMethod("sort")

Ugly, but then so is sort.list....

           -s



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