emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shouldn't records be sequences?


From: Štěpán Němec
Subject: Re: Shouldn't records be sequences?
Date: Sun, 12 Apr 2020 19:02:26 +0200
User-agent: Notmuch/0.29.3 (https://notmuchmail.org) Emacs/28.0.50 (x86_64-pc-linux-gnu)

On Sun, 12 Apr 2020 12:30:26 -0400
Stefan Monnier wrote:

>> Records currently seem a bit weird: `aref', `cl-loop''s "across" clause
>> (which uses `aref'), `copy-sequence' support them; `substring' (which
>> does support vectors) and other sequence functions do not.
>
> My opinion is that records are not sequences, just like C's `structs`
> and Java's objects are not sequences (e.g. it doesn't make much sense to
> concatenate records or to take subsequences of them).  Some of our
> builtin functions operating on sequences also work on records, but
> that's only motivated by the need for backward compatibility with code
> which used to expect `cl-defstruct` to use vectors instead of records.

I think that makes sense, quite possibly more sense than the other way
("records are sequences"), but shouldn't the current state, where some
sequence functions work with records and some do not, and (info "(elisp)
Records") explicitly mentions `aref' and `copy-sequence', be improved in
some way?

IOW, if records really are "much like a vector" (to quote the manual
section), is there any reason not to make the other sequence functions
support them? Alternatively, if their being like a vector is only an
implementation detail, does it make sense to expose that in Lisp at all
and document it?

Thanks,

  Štěpán



reply via email to

[Prev in Thread] Current Thread [Next in Thread]