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: Clément Pit-Claudel
Subject: Re: If records are not sequences, why does aref work on records?
Date: Fri, 7 Apr 2017 13:59:43 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 2017-04-07 12:56, Paul Eggert wrote:
> 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.

Won't this break things, though? I thought cl-defstruct now produced record, so 
will all code that used aref on cl-defstructs need to be updated?

(I use aref on things defined with cl-defstruct from time to time. The latest 
example was a function on binary trees, defined as a union type of two records 
(one type of record for branches, and one type of record for leaves).  Both 
types carried the same information in the first slot, which allowed me to 
replace (if (branch-p x) (branch-v x) (leaf-v x)) by (aref x 1).  This made a 
difference, performance-wise.)

Cheers,
Clément.



reply via email to

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