emacs-devel
[Top][All Lists]
Advanced

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

Re: master 8f0f851: * lisp/autoarg.el: Use lexical binding.


From: Noam Postavsky
Subject: Re: master 8f0f851: * lisp/autoarg.el: Use lexical binding.
Date: Wed, 29 Apr 2020 11:05:20 -0400

On Tue, 28 Apr 2020 at 22:35, Vladimir Sedach <address@hidden> wrote:

> Drew Adams <address@hidden> writes:
> > Why was RESULT deprecated?
>
> That is indeed bizarre. Why break existing Elisp code? David
> Touretzky provides lots of examples of how to use RESULT with DOTIMES
> and DOLIST in _Common Lisp: A Gentle Introduction_.

I think it's useful to look at a couple of concrete examples from
there. I found it at <https://www.cs.cmu.edu/~dst/LispBook/book.pdf>.
There is this kind of usage (page 345):

    (defun it-intersection (x y)
      (let ((result-set nil))
        (dolist (element x result-set)
          (when (member element y)
            (push element result-set)))))

The argument for deprecating the RESULT param is mainly because code
like this is (arguably) clearer when written

    (defun it-intersection (x y)
      (let ((result-set nil))
        (dolist (element x)
          (when (member element y)
            (push element result-set)))
        result-set))

Because it's easier to quickly pick out what the return value is.
Obviously it's a matter of taste to some degree though.

There's another kind of usage that isn't as easily replaced (page 343):

    (defun check-all-odd (list-of-numbers)
      (dolist (e list-of-numbers t)
        (format t "~&Checking ~S..." e)
        (if (not (oddp e)) (return nil))))

But this relies on dolist establishing a block that be used with
return. So in elisp, this should be done with cl-dolist which I
believe everyone agrees will always support the RESULT argument.



reply via email to

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