Subject: bug#7408: 23.2.1 dolist -- subr.el and cl-macs differ with nil-block return

From: Jari Aalto <[email-masked]>
Date: Fri, 19 Nov 2010 00:02:39 +0200

2010-11-17 15:39 Stefan Monnier <[email-masked]>:
>> Is the explanation (I'm not familiar with the history) that at the time
>> cl.el was added there was no dolist in core Emacs, so there was no
>> perceived need to call it dolist* as in other similar cases (mapcar*,
>> defun* etc)? (In that case my sincere disdain would go for the person
>> who introduced dolist into subr.el later without addressing the naming
>> clash.)
>
> AFAIK subr.el's dolist and dotimes are 100% compatible with
> CL's definition.  Of course, if you want to call `return' in there,
> you'll need to define `return', which is only provided by CL so you need
> to (require 'cl).
>
2010-11-17 15:39 Stefan Monnier <[email-masked]>:
>> The 'return' has been integral part of 'dolist' since the start.
>
> Who cares?

There happens to be people that care.

> Show me a piece of code which would work with CL's dolist (but without
> CL's return) and yet doesn't work with subr.el's dolist.

As per request:

    - "if you want to call `return' in there, you'll need to define `return"
    - "dolist and dotimes are 100% compatible with CL's definition."

Jari

    $ emacs -Q

    (progn
      (autoload 'return "cl-macs" nil nil 'macro)
      (dolist (elt '(1 2))
        (return elt)))

    Debugger entered--Lisp error: (no-catch --cl-block-nil-- 1)
      cl-block-throw(--cl-block-nil-- 1)
      (return-from nil elt)
      (return elt)
      (while --dolist-tail-- (setq elt (car --dolist-tail--)) (return elt) (setq --dolist-tail-- (cdr --dolist-tail--)))
      (let ((--dolist-tail-- ...) elt) (while --dolist-tail-- (setq elt ...) (return elt) (setq --dolist-tail-- ...)))
      (dolist (elt (quote ...)) (return elt))
      (progn (autoload (quote return) "cl-macs" nil nil (quote macro)) (dolist (elt ...) (return elt)))
      eval((progn (autoload (quote return) "cl-macs" nil nil (quote macro)) (dolist (elt ...) (return elt))))
      eval-last-sexp-1(nil)
      eval-last-sexp(nil)
      call-interactively(eval-last-sexp nil nil)