[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Rationalising c[ad]\{2,5\}r.
From: |
Stefan Monnier |
Subject: |
Re: Rationalising c[ad]\{2,5\}r. |
Date: |
Thu, 12 Mar 2015 09:53:13 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> 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
- Re: Rationalising c[ad]\{2,5\}r., (continued)
- Re: Rationalising c[ad]\{2,5\}r., Thien-Thi Nguyen, 2015/03/11
- Re: Rationalising c[ad]\{2,5\}r., Alan Mackenzie, 2015/03/11
- Re: Rationalising c[ad]\{2,5\}r., Artur Malabarba, 2015/03/11
- Re: Rationalising c[ad]\{2,5\}r., Alan Mackenzie, 2015/03/12
- Re: Rationalising c[ad]\{2,5\}r., Artur Malabarba, 2015/03/12
- Re: Rationalising c[ad]\{2,5\}r.,
Stefan Monnier <=
- Re: Rationalising c[ad]\{2,5\}r., Alan Mackenzie, 2015/03/13
- RE: Rationalising c[ad]\{2,5\}r., Drew Adams, 2015/03/13
- Re: Rationalising c[ad]\{2,5\}r., Stefan Monnier, 2015/03/13
- Re: Rationalising c[ad]\{2,5\}r., Alan Mackenzie, 2015/03/13
- Re: Rationalising c[ad]\{2,5\}r., Stefan Monnier, 2015/03/13