GNU bug report logs - #73874
29.4; Inconsistent cl-loop behavior with Common Lisp

Previous Next

Package: emacs;

Reported by: Bohong Huang <bohonghuang <at> qq.com>

Date: Sat, 19 Oct 2024 07:41:01 UTC

Severity: normal

Found in version 29.4

Full log


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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Bohong Huang <bohonghuang <at> qq.com>
Cc: 73874 <at> debbugs.gnu.org
Subject: Re: bug#73874: 29.4; Inconsistent cl-loop behavior with Common Lisp
Date: Sat, 2 Nov 2024 23:06:29 -0700
Bohong Huang <bohonghuang <at> qq.com> writes:

> Hello, Emacs developers! When I was porting a Common Lisp library to
> Emacs Lisp, I found that the following minimal code example fails the
> assertion in Emacs Lisp:
>
> ```lisp
> (cl-loop for i in '(1 2 3)
>          for j = (1- i)
>          and k = (1+ i)
>          do (cl-assert (= i (1+ j) (1- k))))
> ```
>
> But it works fine in any proper Common Lisp implementation:
>
> ```lisp
> (loop for i in '(1 2 3)
>       for j = (1- i)
>       and k = (1+ i)
>       do (assert (= i (1+ j) (1- k))))
> ```
>
> By observing the macro expansion, it seems that `cl-loop` does not
> correctly handle the `for ... and ...` clauses, which should bind
> multiple variables in the current loop context in parallel, but
> `cl-loop` always uses the values from the first iteration.
>
> Thank you in advance for your time on this issue.

Is this a duplicate of Bug#72753?

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72753




This bug report was last modified 188 days ago.

Previous Next


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