[R] [Rd] Semantics of sequences in R

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Mon Feb 23 13:24:18 CET 2009

Stefan Evert wrote:
>>> can you please stop repeating this nonsense?  I don't think anybody
>>> ever claimed that vectors can be considered list.
>> yes, it is nonsense.  yes, there is one person who repeatedly made this
>> claim.  please read the archives; specifically, [1]. note this
>> statement:
>>     "Note that any vector can be considered to be a list."
>> [1] https://stat.ethz.ch/pipermail/r-help/2009-February/186932.html
> Sorry, I missed that one.  Unfortunately I haven't kept a copy of the
> posting I was referring to and I can't find a page that allows me to
> search the February archives.
>> when you're talking about nonsense, please attribute it to the right
>> person.
> Well, you _are_ repeating it, aren't you?  Since you are so pedantic
> about the semantics of programming languages, you certainly can't
> complain about that statement.
> I take back everything I wrote after that on the matter. Sorry!

it never happened.

>>> It's rather the other way round: lists can also be seen as vectors to
>>> R (possibly they are implemented as such, but I don't much about the
>>> internals of R).
>> not *all* lists are vectors;  pairlists are not, though they are lists.
> Didn't someone just say that it would probably be best to hide
> pairlists from users entirely?

this was just a suggestion from a user.  it has no legal power.

>> but
>>    mode(unlist(a))
>>    # "numeric"
>>    class(unlist(a))
>>    # integer
> Well, yes, that was the solution, wasn't it?  Since a list is a
> vector, you have to unlist() it explicitly to turn it into a "plain"
> vector. Except that it flattens the list, which is an entirely
> different operation than a mere mode change.  So I don't really
> understand what that comment was supposed to mean.

just to make clear (to others, if not to you) that unlisting a list
produces a non-list vector which is not a list.  it was not supposed to
be a counterexample.

>>> Honestly, I can't think of a situation where I would want to do than
>>> in R.  In a Perl script, quite likely; but this is a kind of data
>>> manipulation that R wasn't really designed for IMHO.
>> irrespectively of how exotic sorting lists of vectors can be in a system
>> for the manipulation of a comprehensive range of sorts of data, having a
>> procedure called 'sort.list' complain about being called on a list is a
>> sure source of confusion.
> Only until you read ?sort, isn't it?

no.  an interface -- and function names are part of an interface to the
system -- should be as intuitive as possible.  you can always demand
users to carefully read every single bit of the docs, but why make their
life more difficult than necessary?  any guess as to why people tend not
to code in malbolge?

>> how much is it likely that people will want to sort complex numbers in a
>> system where complex numbers are incomparable?
> I can only say that I'm not likely to want that either, but obviously
> someone did so it was implemented (I am sure that one factor leading
> to their decision was that this method does not clash with an existing
> function).

... while it introduced an ugly incoherence to the language.


More information about the R-help mailing list