From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Brinkhoff Newsgroups: gmane.emacs.devel Subject: Re: If records are not sequences, why does aref work on records? Date: Fri, 07 Apr 2017 19:27:05 +0200 Organization: nocrew Message-ID: <86h9202knq.fsf@molnjunk.nocrew.org> References: <86pogo4vty.fsf@molnjunk.nocrew.org> <8360igof0k.fsf@gnu.org> <867f2w4qdk.fsf@molnjunk.nocrew.org> <0e6a0a16-8133-b2bc-404a-d0016f0c655e@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1491586065 17911 195.159.176.226 (7 Apr 2017 17:27:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 7 Apr 2017 17:27:45 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 07 19:27:41 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwXfa-0003fm-60 for ged-emacs-devel@m.gmane.org; Fri, 07 Apr 2017 19:27:34 +0200 Original-Received: from localhost ([::1]:51992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwXfg-0003Ka-5Z for ged-emacs-devel@m.gmane.org; Fri, 07 Apr 2017 13:27:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwXfZ-0003KR-Ck for emacs-devel@gnu.org; Fri, 07 Apr 2017 13:27:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwXfW-0006ue-7a for emacs-devel@gnu.org; Fri, 07 Apr 2017 13:27:33 -0400 Original-Received: from [195.159.176.226] (port=46470 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cwXfW-0006uM-0o for emacs-devel@gnu.org; Fri, 07 Apr 2017 13:27:30 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cwXfC-0001TO-30 for emacs-devel@gnu.org; Fri, 07 Apr 2017 19:27:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 32 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:fetoDt3wmdbD8ipp5X5BJx/TpUA= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213765 Archived-At: 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.