From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: Is this a bug in while-let or do I missunderstand it? Date: Sat, 9 Nov 2024 16:29:54 +0700 Message-ID: References: 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="15572"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" To: arthur miller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 09 10:30:50 2024 Return-path: Envelope-to: ged-emacs-devel@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 1t9hnu-0003ye-FI for ged-emacs-devel@m.gmane-mx.org; Sat, 09 Nov 2024 10:30:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9hnG-0005KJ-R8; Sat, 09 Nov 2024 04:30:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9hnF-0005JX-2v for emacs-devel@gnu.org; Sat, 09 Nov 2024 04:30:09 -0500 Original-Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9hnD-0003DX-FT for emacs-devel@gnu.org; Sat, 09 Nov 2024 04:30:08 -0500 Original-Received: by mail-ua1-x935.google.com with SMTP id a1e0cc1a2514c-84fd057a973so1160156241.3 for ; Sat, 09 Nov 2024 01:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731144606; x=1731749406; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ej4sLx6gXvcJ7BbIMfaRy0TwbiOlURod0/SmxOttU2w=; b=CyW/++vUeYGvfVG+021X421Fb8z65mivhKvyXSVfWI5oNoTl9Hdrp1jeiL9AWvW5sG ZY0itT5wTWLyX0qF2THoYK4GDqqiqgh2JpoSw2xq0SwSAOn9WLbc2k4ijHrBXYBHrYOq A2yexLJURwq3iHjb2Ng2WuC8Af2DyMi+ntIZJCmnjIbh9iZRSb9srBNPgzQ2cYEPHHEf Edo7PwNAEYxwoLzlVx5FlhSaupny/68Lb/2V3t2xgA/+VOpwvxwoQ2Id4XAM6AIIAzUJ zgQTCqeZ9cBP4HCx1ZQefGXR+VDteRWvNO94N/TDmxRJxiLORru87ZfxMeab+6cd0CTz YWtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731144606; x=1731749406; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ej4sLx6gXvcJ7BbIMfaRy0TwbiOlURod0/SmxOttU2w=; b=kccdb6dKwyTgVGGNz8yho09WwTFXP3tgWs9Vl5f5Nhfuc8rdj3rW6iu8SVmKUhb+KT d6zL5pgarw4SUofXpJzDh/Xzx9v//vURqv8mdEcNbbZfPgqy+hZSvMHjlbPeo7kLhgIL hQpnlTBRJgs8FQv5y0GUgxR3ceu1gk1bVNr/QM6zGrQRu3unxobxto46CFLqaoJ2Z9GI woP1qXZrST5gak4ShExLx8AxeIk2AdDvt0UPbGUHp6Wx8WSHayOoq2mUR2PBf5vjqtKL HCqluWTZXIS3LXabIhSWD5/grM4ZNza5Qd0bxMKCf9RYXty8OTKt4B1UonLkCWzehfud 3Kbw== X-Gm-Message-State: AOJu0YzWycE6YnNguZ3VavG6jVuArN0DD0gZZG8vaX7us7A+eW+XLT/v nPAlEmfkdVCIbEMi79K9GXXpVU5CZT5nhDeqBbTC+ZbQEikXPd5fMEwX6u25ySCALm9TCruLeA7 NINSuIP9f5upZwc89bytMU/AIY4gmYoyoaQg= X-Google-Smtp-Source: AGHT+IGwbKSjybmv/xurs6RReFzvJ1/DtrCxhgFTE5M1kZKKT0O/fOA0cZMy4/NwXKCCbwb+PMPyh4FTygKqg9j16Z4= X-Received: by 2002:a05:6102:c4f:b0:4a4:9253:9b9d with SMTP id ada2fe7eead31-4aae162a0cemr5989606137.18.1731144605807; Sat, 09 Nov 2024 01:30:05 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::935; envelope-from=yurivkhan@gmail.com; helo=mail-ua1-x935.google.com 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325326 Archived-At: On Sat, 9 Nov 2024 at 01:44, arthur miller wrote: > > (progn > (while-let ((run t)) > (message "Running") > (setf run nil)) > (message "out of loop")) > > It ends in infinite recursion. setf/setq have no effect on the lexical va= riable. Probably not infinite recursion but infinite loop. Why would you expect anything else? =E2=80=98while-let=E2=80=99 is document= ed as: Bind variables according to SPEC and conditionally evaluate BODY. Evaluate each binding in turn, stopping if a binding value is nil. If all bindings are non-nil, eval BODY and repeat. In your case, the sequence is: 1. Evaluate the expression =E2=80=98t=E2=80=99 in the first (and only) bind= ing. This yields =E2=80=98t=E2=80=99. 2. Bind the result of step 1, =E2=80=98t=E2=80=99, to local variable =E2=80= =98run=E2=80=99. 3. Check if =E2=80=98run=E2=80=99 is nil. It isn=E2=80=99t, so proceed to s= tep 4. 4. There are no more bindings. Run the body. 4a. Evaluate =E2=80=98(message "Running")=E2=80=99. 4b. Evaluate =E2=80=98(setf run nil)=E2=80=99. This changes the value of = =E2=80=98run=E2=80=99 to nil. 5. Repeat from step 1. Re-evaluating every binding=E2=80=99s expression is expected. Consider this= usage: (while-let ((values-to-process (get-values))) (while values-to-process (setq value (pop values-to-process)) (process value))) At the end of each outer loop=E2=80=99s iteration, =E2=80=98values-to-proce= ss=E2=80=99 is nil, but you don=E2=80=99t want to break out of the outer loop immediately, you want to check if there is more work to do.