Skip to content
Prev 31531 / 63424 Next

Semantics of sequences in R

Berwin A Turlach wrote:
would it, really?  if sort.list were, in addition to sorting atomic
vectors (can-be-considered-lists), able to sort lists, how likely would
this be to break old code?  can you give one concrete example, and
suggest how to estimate how much old code would involve the same issue?

sort.list, to be applied to an atomic vector, must be called explicitly
on the vector, because calling sort will not automatically dispatch to
sort.list (right?).   so allowing sort.list to sort lists does not
change anything in this respect -- except for that, as i suggested, if
sort.list were requiring an explicit comparator, you'd have to add one
wherever sort.list is called, but to accomodate for old code sort.list
could actually check whether the argument is not an atomic vector.

how much old code could be relying on the fact that sort.list raises an
error when given a list?  i suspect it's fairly unlikely that any single
piece of code does;  and if so, allowing sort.list to sort lists would
not change anything here either.
which hints that "potentially will break a lot (?) of existing code" is
a rather unlikely event.
i don't understand the first part:  "flexible enough data structure such
that defining a sort() command for them makes no sense" makes no sense.

as to "it could only work in very specific circumstances" -- no, it
would work for any list whatsoever, provided the user has a correctly
implemented comparator.  for example, i'd like to sort a list of vectors
by the vectors' length -- is this a very exotic idea?
indeed, he was blurring the concepts instead of referring to concrete
documentation with clear specified meaning of the terms he used.
yes;  and you can always say that 'vectors can be considered electrical
charges', or better, 'vectors can be considered electrical charges, in
some sense'.

what sense of 'list' are you using here?  i'd rather use the term
'array', unless confusing the user is the real purpose.  (and to be
really picky, you do not store numbers.)
clearly, you can say anything you like, and then add 'i was not talking
about x as defined by y'.  the art  is to talk about x as defined by y.
berwin, it's been a tradition on this list to discourage people from
commenting on the design and implementation of r whenever they think
it's wrong.  you really should be doing the opposite.  as a chinese
proverb says, a gem cannot be polished without friction.  friction seems
to be what you fear a lot.
the problem, is, r users have to learn lots and lots of *bad* and
*messy* design to get up and running without devils catching them behind
every corner.  in principle, you're absolutely right;  the problem lies
in the amount of effort a user has to make to avoid confusion while
using r  (where 'using' means a bit more than simply fitting and
plotting a model).

cheers,
vQ