Comment 2 for bug 775712

Revision history for this message
Roman Marynchak (roman-marynchak) wrote :

I support Christophe in this discussion. Also, look at this macroexpansion, there is no DOLIST when it comes to the places in the compiler where such analysis is possible:

* (macroexpand '(dolist (i '(0 1 2) (nreverse list))
                              (push (lambda () i) list)))

(BLOCK NIL
  (LET ((#:N-LIST597 '(0 1 2)))
    (TAGBODY
     #:START598
      (UNLESS (ENDP #:N-LIST597)
        (LET* ((#:TMP599 (TRULY-THE (MEMBER 2 1 0) (CAR #:N-LIST597)))
               (I #:TMP599))
          (SETQ #:N-LIST597 (CDR #:N-LIST597))
          (TAGBODY (PUSH (LAMBDA () I) LIST)))
        (GO #:START598))))
  (LET ((I NIL))
    I
    (NREVERSE LIST)))

At this moment, DOLIST context is lost, so the compiler cannot warn you about it. The alternative solution is to describe this somewhere in the manual (to show the behavior of this code in SBCL).