From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Okam Newsgroups: gmane.emacs.help Subject: Re: Function value changes after running function? Date: Fri, 05 Feb 2021 17:27:34 +0000 Message-ID: References: <87tuqr431d.fsf@zoho.eu> <17c2df48-8e9a-4c57-dfbf-b058d2836395@protonmail.com> Reply-To: Okam Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11440"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 06 00:34:12 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8Ac8-0002rk-2L for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 06 Feb 2021 00:34:12 +0100 Original-Received: from localhost ([::1]:60546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8Ac7-0004XX-2c for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 05 Feb 2021 18:34:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l84tc-0001Xr-9C for help-gnu-emacs@gnu.org; Fri, 05 Feb 2021 12:27:53 -0500 Original-Received: from mail1.protonmail.ch ([185.70.40.18]:11680) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l84tY-00073q-1N for help-gnu-emacs@gnu.org; Fri, 05 Feb 2021 12:27:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1612546058; bh=Em5B+dsG0cFwztp1BCvGaV2wUrJn+4pnMeF5Y3gKNio=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=vfjECkotmEo4ZFdVb7/L0nNhNu8cWN1rYCqbIlYcPS8hqIe2bbGEsNLEidTFXshDX M/H45rz4nh3GOWFcG0XSYp6v15mgKzI1yfio52GftOSwUKnWcI62Gx5iY5rf1o2lEO NNk/LiiSW1eZrGTaGoumHKErhsETShgTPYuVIsYo= In-Reply-To: Received-SPF: pass client-ip=185.70.40.18; envelope-from=okamsn@protonmail.com; helo=mail1.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 05 Feb 2021 18:33:26 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127627 Archived-At: On 2/5/21 10:48 AM, Stefan Monnier wrote: >=20 >> 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: >=20 > In the current situation, the problem is: >=20 > (setq loopy--main-body (nreverse loopy--main-body) > loopy--with-vars (nreverse loopy--with-vars)) >=20 > which reverses the "with vars" received as arguments. > If you replace `nreverse` with `reverse` here, this particular problem > should disappear. >=20 > 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 >=20 > (setq loopy--with-vars (cdr arg))) >=20 > with >=20 > (setq loopy--with-vars (reverse (cdr arg)))) >=20 > so that the subsequent `nreverse` puts them back in the original order. >=20 >=20 > Stefan >=20 >=20 Thank you. That does prevent the error, but would you please explain=20 (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=20 does? The return value of `symbol-function` makes it look like the=20 function passes different arguments to the macro after the first=20 invocation. Is that a misleading return value, or is that actually=20 happening? If that is what happens, why does that happen?