GNU bug report logs - #76476
Make cl-first, cl-second, ..., cl-tenth part of Emacs Lisp

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Fri, 21 Feb 2025 18:42:02 UTC

Severity: wishlist

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Drew Adams <drew.adams <at> oracle.com>
To: Stefan Kangas <stefankangas <at> gmail.com>, "76476 <at> debbugs.gnu.org" <76476 <at> debbugs.gnu.org>
Cc: "eliz <at> gnu.org" <eliz <at> gnu.org>, "acorallo <at> gnu.org" <acorallo <at> gnu.org>, "monnier <at> iro.umontreal.ca" <monnier <at> iro.umontreal.ca>
Subject: bug#76476: Make cl-first, cl-second, ..., cl-tenth part of Emacs Lisp
Date: Fri, 21 Feb 2025 20:39:21 +0000
> Severity: wishlist
> 
> I propose making the following functions from cl-lib.el a part of
> Emacs Lisp proper (i.e. defined in subr.el):
> 
>     first
>     second
>     third
>     fourth
>     fifth
>     sixth
>     seventh
>     eight
>     ninth
>     tenth
>     rest
> 
> This would allow converting code such as:
> 
>     (mapcar (lambda (thing) (car (cdr (cdr (cdr thing))))) ...)
>     (mapcar (lambda (thing) (cadddr thing)) ...)
>     (mapcar (lambda (thing) (nth 3 thing)) ...)

Aka (mapcar #'cadddr ...)  ;-)

> to the IMHO, more direct and readable:
> 
>     (mapcar #'fourth ...)
> 
> I'm adding `rest' to the list as well, as the natural corollary to
> `first'.
> 
> Which would be used is obviously situational, and should be left to
> whoever is touching that code.  There is no general need to "upgrade"
> old code to prefer these new functions.
> 
> Thoughts?

Since you asked...

There are about 8 zillion things in cl-* that it would
be more useful to add to Elisp (without prefix `cl-')
than those functions.

That said, it wouldn't hurt to add those functions, but
why not do something more useful while you're at it?

E.g., something like cl-case (sans cl-) should have been
added to Elisp eons ago.  (And in fact if you loaded
cl.el you got it as `case', not `cl-case', originally.)

Better to look for more useful parts of cl-lib...

This bug report was last modified 143 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.