From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Rationalising c[ad]\{2,5\}r. Date: Thu, 12 Mar 2015 09:53:13 -0400 Message-ID: References: <20150311214324.GA2952@acm.fritz.box> <87zj7jb2p2.fsf@zigzag.favinet> <20150311230054.GB2952@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1426168434 12983 80.91.229.3 (12 Mar 2015 13:53:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Mar 2015 13:53:54 +0000 (UTC) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 12 14:53:46 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YW3YW-0006xu-W8 for ged-emacs-devel@m.gmane.org; Thu, 12 Mar 2015 14:53:45 +0100 Original-Received: from localhost ([::1]:60063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW3YR-0000Qx-9E for ged-emacs-devel@m.gmane.org; Thu, 12 Mar 2015 09:53:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW3Y7-0000Nd-Uj for emacs-devel@gnu.org; Thu, 12 Mar 2015 09:53:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YW3Y3-0000in-N3 for emacs-devel@gnu.org; Thu, 12 Mar 2015 09:53:19 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:29819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW3Y3-0000iX-KJ for emacs-devel@gnu.org; Thu, 12 Mar 2015 09:53:15 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArwTAPOG1lRFpZs2/2dsb2JhbABbgwaDX4VTwGUEAgKBDUQBAQEBAQF8hA0BBAFWIwULCw4mEhQYDSQuiAoIziMBAQEHAgEfj3gHhCoFqXKBRSKCAhyBbCKCcwEBAQ X-IPAS-Result: ArwTAPOG1lRFpZs2/2dsb2JhbABbgwaDX4VTwGUEAgKBDUQBAQEBAQF8hA0BBAFWIwULCw4mEhQYDSQuiAoIziMBAQEHAgEfj3gHhCoFqXKBRSKCAhyBbCKCcwEBAQ X-IronPort-AV: E=Sophos;i="5.09,536,1418101200"; d="scan'208";a="113371078" Original-Received: from 69-165-155-54.dsl.teksavvy.com (HELO pastel.home) ([69.165.155.54]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Mar 2015 09:53:14 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 033FA2092; Thu, 12 Mar 2015 09:53:13 -0400 (EDT) In-Reply-To: <20150311230054.GB2952@acm.fritz.box> (Alan Mackenzie's message of "Wed, 11 Mar 2015 23:00:54 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183820 Archived-At: > I propose the following solution: all these defuns should be in subr.el, Emacs lived with just car/cdr for many many years. Then someone saw that (car (cdr ...)) was fairly common in Elisp and decided that it was worth moving cl.el's cadr/caar/cadr/cddr to subr.el (tho only those, keeping the longer ones in cl.el). While there are a few uses of cXXr with more than 2 Xs, these aren't very common, and I personally find them to be not terribly readable (basically, car/cdr feel a bit like assembly-level programming to me, since they access structure elements without giving them a name). Additionally, these are usually somewhat inefficient (because some of the inner car/cdr could/should be shared between different calls, but our byte-compiler doesn't know how to do common-subexpression-elimination, so it's better to spell them out as something like (cadr (cadr x)) and then to manually move the inner cadr to a let-binding to share it between various cXXr calls). So while I'm not dead-set against adding many more cXXXr to subr.el, I'm not in favor of it, since I think it encourages a poorly-readable and inefficient programming style. This said, I am in favor of moving cl--compiler-macro-cXXr to subr.el and making use of it (in place of inlining) for cadr/caar/cddr/cdar. [ It's my fault if it's not done that way yet, but that was just a mistake on my part. ] > Just one thing, though, since `number-sequence' is also defined in > subr.el, I'd have to wrap it in `eval-and-compile' to be able to use it > in my macros. I'm not sure it's necessary, because subr.el is preloaded (and preloaded early, i.e. before eager macro-expansion is enabled). Stefan