GNU bug report logs - #72753
Different output between SBCL `loop` and Emacs `cl-loop`

Previous Next

Package: emacs;

Reported by: Okamsn <okamsn <at> protonmail.com>

Date: Thu, 22 Aug 2024 01:57:01 UTC

Severity: normal

To reply to this bug, email your comments to 72753 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#72753; Package emacs. (Thu, 22 Aug 2024 01:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Okamsn <okamsn <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 22 Aug 2024 01:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Okamsn <okamsn <at> protonmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Different output between SBCL `loop` and Emacs `cl-loop`
Date: Thu, 22 Aug 2024 01:55:07 +0000
Hello,

The following in SBCL 2.1.11 produces 3, which I expected.

     (loop for i in '(1 2 3)
           for j from 1
           finally (return j))

The following in Emacs 29 produces 4, which I did not expect.

     (cl-loop for i in '(1 2 3)
              for j from 1
              finally (cl-return j))

This is a simplified example that only shows the difference.

I don't know what the standard behavior is, but I personally believe 
that the SBCL output makes more sense.

Thank you.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72753; Package emacs. (Thu, 22 Aug 2024 07:59:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: Okamsn <okamsn <at> protonmail.com>, 72753 <at> debbugs.gnu.org
Subject: Re: bug#72753: Different output between SBCL `loop` and Emacs
 `cl-loop`
Date: Thu, 22 Aug 2024 09:57:08 +0200
On Thu, 22 Aug 2024 01:55:07 +0000 Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> wrote:

> Hello,
>
> The following in SBCL 2.1.11 produces 3, which I expected.
>
>      (loop for i in '(1 2 3)
>            for j from 1
>            finally (return j))

I get the same result with SBCL 2.4.5.

> The following in Emacs 29 produces 4, which I did not expect.
>
>      (cl-loop for i in '(1 2 3)
>               for j from 1
>               finally (cl-return j))

I also get 4 with Emacs built from master.

> This is a simplified example that only shows the difference.
>
> I don't know what the standard behavior is, but I personally believe
> that the SBCL output makes more sense.

FWIW, GNU CLISP 2.49.93+ (built from the git repo) returns 4, not 3, for
the above Common Lisp loop sexp.

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72753; Package emacs. (Thu, 22 Aug 2024 07:59:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72753; Package emacs. (Fri, 23 Aug 2024 11:23:02 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: <bug-gnu-emacs <at> gnu.org>
Cc: okamsn <at> protonmail.com, Stephen Berman <stephen.berman <at> gmx.net>,
 72753 <at> debbugs.gnu.org
Subject: Re: bug#72753: Different output between SBCL `loop` and Emacs
 `cl-loop`
Date: Fri, 23 Aug 2024 13:21:07 +0200
>>>>> On Thu, 22 Aug 2024 09:57:08 +0200, Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> said:

    >> 
    >> I don't know what the standard behavior is, but I personally believe
    >> that the SBCL output makes more sense.

    Stephen> FWIW, GNU CLISP 2.49.93+ (built from the git repo) returns 4, not 3, for
    Stephen> the above Common Lisp loop sexp.

The CLHS section 6.1.7.2 says

"The finally construct causes the supplied compound-forms to be
evaluated in the loop epilogue *after* normal iteration terminates."
(emphasis mine).

To me that means all bets are off regarding the values of variables
created in the context of the loop iteration. But we should ask a
Common Lisp expert to be sure.

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72753; Package emacs. (Fri, 23 Aug 2024 11:24:02 GMT) Full text and rfc822 format available.

This bug report was last modified 297 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.