all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Okam <okamsn@protonmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Function value changes after running function?
Date: Fri, 05 Feb 2021 17:27:34 +0000	[thread overview]
Message-ID: <a860fe18-eb90-1a3f-43c9-2865c4c2a65b@protonmail.com> (raw)
In-Reply-To: <jwvblcy7c6h.fsf-monnier+emacs@gnu.org>

On 2/5/21 10:48 AM, Stefan Monnier wrote:
> 
>> 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
> 
> 

Thank you.  That does prevent the error, but would you please explain 
(or point me to where I could learn) how `nreverse` causes this error?

Why would invoking the function a second time change what the function 
does? The return value of `symbol-function` makes it look like the 
function passes different arguments to the macro after the first 
invocation. Is that a misleading return value, or is that actually 
happening? If that is what happens, why does that happen?




  reply	other threads:[~2021-02-05 17:27 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
2021-02-05 17:27       ` Okam [this message]
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=a860fe18-eb90-1a3f-43c9-2865c4c2a65b@protonmail.com \
    --to=okamsn@protonmail.com \
    --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.