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: Stefan Monnier
Subject: Re: Shouldn't records be sequences?
Date: Sun, 12 Apr 2020 13:23:10 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> 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.
> Isn't performance part of it too?

It could be relevant, tho I can't remember it being a factor in practice.

> A recent example: I have a list of records that I display to users,
> using a custom sort order (a list of record fields).  It's convenient
> to be able to go from list of fields to list of array offsets once,
> and then use those offsets in the comparison function (this is similar
> to what I'd do with C structs).

Not sure how that relates to treating them as sequences.
We do want some way to work at the lower level (i.e. access the N'th
field), which is currently done with `aref` but could be done by
a `record-ref` instead.


        Stefan


PS: The clean equivalent in Elisp would be to use a list of
field-accessors instead of a list of fields.  This also saves you from
converting to a list of array offsets.  But (funcall accessor x) is
probably significantly slower than (aref x offset), indeed.  OTOH I can
imagine an implementation of Elisp where the cost is comparable
(because the `funcall` is cheap enough).






reply via email to

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