all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: Rationalising c[ad]\{2,5\}r.
Date: Thu, 12 Mar 2015 09:53:13 -0400	[thread overview]
Message-ID: <jwvioe64a7r.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20150311230054.GB2952@acm.fritz.box> (Alan Mackenzie's message of "Wed, 11 Mar 2015 23:00:54 +0000")

> 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



  parent reply	other threads:[~2015-03-12 13:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11 21:43 Rationalising c[ad]\{2,5\}r Alan Mackenzie
2015-03-11 22:00 ` Drew Adams
2015-03-11 22:54   ` Artur Malabarba
2015-03-12  1:51     ` Drew Adams
2015-03-12  9:54       ` Artur Malabarba
2015-03-12 14:01         ` Drew Adams
2015-03-12  4:34     ` Stephen J. Turnbull
2015-03-12 10:15       ` Artur Malabarba
2015-03-12 10:30   ` Alan Mackenzie
2015-03-12 14:03     ` Drew Adams
2015-03-11 22:15 ` Thien-Thi Nguyen
2015-03-11 23:00   ` Alan Mackenzie
2015-03-11 23:36     ` Thien-Thi Nguyen
2015-03-12  1:35       ` Samuel W. Flint
2015-03-12  0:52     ` Artur Malabarba
2015-03-12  8:56       ` Alan Mackenzie
2015-03-12 10:15         ` Artur Malabarba
2015-03-12 13:53     ` Stefan Monnier [this message]
2015-03-13 16:41       ` Alan Mackenzie
2015-03-13 16:47         ` Drew Adams
2015-03-13 20:38         ` Stefan Monnier
2015-03-13 21:36           ` Alan Mackenzie
2015-03-13 23:00             ` Stefan Monnier
2015-04-05 13:00               ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvioe64a7r.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.