all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Function value changes after running function?
Date: Fri, 05 Feb 2021 10:48:27 -0500	[thread overview]
Message-ID: <jwvblcy7c6h.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 17c2df48-8e9a-4c57-dfbf-b058d2836395@protonmail.com

> 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	other threads:[~2021-02-05 15:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05  2:41 Function value changes after running function? okamsn+emacs-help
2021-02-05  3:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-05 15:34   ` okamsn+emacs-help
2021-02-05 15:48     ` Stefan Monnier [this message]
2021-02-05 17:27       ` Okam
2021-02-05 15:24 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvblcy7c6h.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.