emacs-devel
[Top][All Lists]
Advanced

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

Re: If records are not sequences, why does aref work on records?


From: Lars Brinkhoff
Subject: Re: If records are not sequences, why does aref work on records?
Date: Fri, 07 Apr 2017 19:27:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Paul Eggert wrote:
>> I think there are only a few functions that wants a sequence but not a
>> record: elt, copy-sequence, concat, reverse, and sort.
>
> It is confusing that aref works on records but copy-sequence etc. do
> not. This behavior of aref is not documented in the aref doc string,
> or in the Lisp manual under aref.

You're right.  I can add that documentation, if that's indeed the way
we want to go.

> How about if we define a new function record-ref to be used on
> records, instead of aref? At the low level this would insulate records
> better from the rest of Emacs Lisp, which I think is the intent -- as
> I understand it, records are supposed to be used to create new types,
> and are not supposed to be sorts of aliases for sequences.

That's one way to go, and I understand that point of view.

I believe there is prior art in XEmacs.  They added special functions to
work with byte-code slots, and removed access with aref.  I don't know
the background, but I note that GNU Emacs never followed suit.

The other point of view might be that aref is already there, works fine
for arrays, byte-code, and other pseudovector types, so it might just as
well be extended to work with records too.  Add to this that old code
using aref on vector structures will keep working if passed a record
structure.

To answer the question in the subject, I initially patterned records
mostly after the byte-code type because they are quite alike.  So that
included using aref to access slots.




reply via email to

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