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: Philipp Stephani
Subject: Re: If records are not sequences, why does aref work on records?
Date: Sat, 08 Apr 2017 11:34:18 +0000



Noam Postavsky <address@hidden> schrieb am Fr., 7. Apr. 2017 um 23:03 Uhr:
On Fri, Apr 7, 2017 at 4:49 PM, Drew Adams <address@hidden> wrote:
>
> I don't understand the backward-compatibility argument.
> A record type has not existed before.  When/where do we
> already have `aref'/`copy-sequence' being applied to
> something other than a sequence/array?

Up until the recent changes, the things produced by cl-defstruct
make-foo functions were vectors with the first element being the
symbol 'cl-struct-foo'. So they could be indexed with aref and copied
with copy-sequence. Now they are "record" objects, but we don't want
to break code that uses aref and copy-sequence on them.


While the manual mentions that vectors or lists are used, it doesn't say that the sequence functions can simply be used. Rather, the implementation as sequence is an implementation detail that users shouldn't rely on. cl-defstruct even creates a copy-FOO function to copy structures, which should be used instead of copy-sequence. Therefore, I think it's fine to not allow copy-sequence and aref on structure types any more, if this change is properly documented. 

reply via email to

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