all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Vladimir Sedach <vas@oneofus.la>
Cc: Michael Heerdegen <michael_heerdegen@web.de>,
	Juanma Barranquero <lekktu@gmail.com>,
	Emacs developers <emacs-devel@gnu.org>,
	Stefan Kangas <stefankangas@gmail.com>,
	Drew Adams <drew.adams@oracle.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: master 8f0f851: * lisp/autoarg.el: Use lexical binding.
Date: Wed, 29 Apr 2020 11:05:20 -0400	[thread overview]
Message-ID: <CAM-tV-8LD+HLh3XU82pVyEEvqTLWYXiiLs5R1p29zjYOw_LPEQ@mail.gmail.com> (raw)
In-Reply-To: <87imhj2faz.fsf@t510.orion.oneofus.la>

On Tue, 28 Apr 2020 at 22:35, Vladimir Sedach <vas@oneofus.la> wrote:

> Drew Adams <drew.adams@oracle.com> 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.



  parent reply	other threads:[~2020-04-29 15:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200419004503.26161.91884@vcs0.savannah.gnu.org>
     [not found] ` <20200419004504.C65772049B@vcs0.savannah.gnu.org>
2020-04-19  6:18   ` master 8f0f851: * lisp/autoarg.el: Use lexical binding Juanma Barranquero
2020-04-20  5:10     ` Stefan Kangas
2020-04-20  5:34       ` Michael Heerdegen
2020-04-20 11:06         ` Noam Postavsky
2020-04-20 13:52       ` Stefan Monnier
2020-04-20 14:55         ` Drew Adams
2020-04-20 16:32           ` Stefan Monnier
2020-04-28  2:14             ` Michael Heerdegen
2020-04-28  2:59               ` Strange compiler warning in `dotimes' (was: master 8f0f851: * lisp/autoarg.el: Use lexical binding.) Michael Heerdegen
2020-04-28 15:32               ` master 8f0f851: * lisp/autoarg.el: Use lexical binding Drew Adams
2020-04-29  0:53                 ` Michael Heerdegen
2020-04-29  0:59                   ` Drew Adams
2020-04-29  1:13                     ` Michael Heerdegen
2020-04-29  1:23                       ` Drew Adams
2020-04-29  2:31                 ` Vladimir Sedach
2020-04-29  3:58                   ` Michael Heerdegen
2020-04-29  4:21                     ` Stefan Monnier
2020-04-29 18:33                     ` Vladimir Sedach
2020-04-29  4:02                   ` Stefan Monnier
2020-04-29 15:05                   ` Noam Postavsky [this message]
2020-04-30  2:26                   ` Richard Stallman
2020-05-16  3:21                     ` Michael Heerdegen
2020-04-29  3:53                 ` Stefan Monnier

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=CAM-tV-8LD+HLh3XU82pVyEEvqTLWYXiiLs5R1p29zjYOw_LPEQ@mail.gmail.com \
    --to=npostavs@gmail.com \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=michael_heerdegen@web.de \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefankangas@gmail.com \
    --cc=vas@oneofus.la \
    /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.