help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function value changes after running function?


From: Stefan Monnier
Subject: Re: Function value changes after running function?
Date: Fri, 05 Feb 2021 10:48:27 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> No, I wrote a macro like `cl-loop` here:
>
> https://github.com/okamsn/loopy
>
> I received a bug report that said that the above function would raise an 
> error after running a second time here:

In the current situation, the problem is:

    (setq loopy--main-body (nreverse loopy--main-body)
          loopy--with-vars (nreverse loopy--with-vars))

which reverses the "with vars" received as arguments.
If you replace `nreverse` with `reverse` here, this particular problem
should disappear.

This said, this `nreverse` reverses the order of the bindings in (with ....)
which maybe isn't what you intended (I suspect that the `nreverse` here
is meant to reverse the bindings added to `loopy--with-vars` via
`push`).
So maybe a better solution is to replace

        (setq loopy--with-vars (cdr arg)))

with

        (setq loopy--with-vars (reverse (cdr arg))))

so that the subsequent `nreverse` puts them back in the original order.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]