emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cl-pushnew and other functions


From: John Wiegley
Subject: Re: cl-pushnew and other functions
Date: Sun, 01 Jul 2012 22:50:49 -0500
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (darwin)

>>>>> Stefan Monnier <address@hidden> writes:

>>>> I think the basic function in CL should just be considered part of the
>>>> Emacs Lisp language,
>>> We simply disagree.
>> Why do we disagree?

> Because I don't want to simply adopt all those Common-Lisp-isms into Elisp.
> A big reason for that is that Elisp is not compiled aggressively, so some
> design choices in Common-Lisp would be too costly in Elisp.

Well, maybe we disagree less than we think we do. :)

If something is ugly, surprising, or has semantics outside what a veteran
Elisper would expect, I think cl- is just fine -- even called-for.

What I really prefer not to see are the everyday staples getting an ugly
prefix, cluttering up mah code.  For example: push, incf, loop,
destructuring-bind (which is already too long), etc.

> Other reasons is that I do not agree with some of Common-Lisp's design
> choices (question of taste).  For a recent example, define-setf-expander is
> ugly and inefficient, so the new "core setf" does not fully support it.

Yeah, I'm totally fine with this.  If there's a callable thing called "setf"
that does what I expect 95% of the time, call me a happy camper.

I'm not advocating CL puritanism in Emacs, by no means.  I just want count-if
and remove-if to be usable, by those names, in code I intend to contribute.
I've rewritten those functions too many times to count now because they aren't
macros.  Enough!

Some CL stuff is also just better than any other equivalent we have in core.
I know loop is a macro, so we can already use it in contributed code (can't
I?), but look how well it aids readability in a use I found for it today

Before:

    (defun gnus-harvest-bbdb-complete-stub (stub)
      (delete
       nil
       (mapcar
        #'(lambda (record)
            (let ((nets (bbdb-record-mail record)))
              (and nets
                   (format "%s <%s>" (bbdb-record-name record)
                           (car nets)))))
        (bbdb-search (bbdb-records) stub nil stub))))

After:

    (defun gnus-harvest-bbdb-complete-stub (stub)
      (loop for record in (bbdb-search (bbdb-records) stub nil stub)
            for nets = (bbdb-record-mail record)
            when nets
            collect (format "%s <%s>" (bbdb-record-name record) (car nets))))

I breathed a sigh of relief there, just reading that again.

John



reply via email to

[Prev in Thread] Current Thread [Next in Thread]