From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Is this a bug in while-let or do I missunderstand it? Date: Sat, 09 Nov 2024 18:44:28 +0200 Message-ID: <861pzkmk5v.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2482"; mail-complaints-to="usenet@ciao.gmane.io" Cc: yuri.v.khan@gmail.com, arthur.miller@live.com, emacs-devel@gnu.org To: "Alfred M. Szmidt" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 09 17:45:17 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 1t9oaK-0000WU-PS for ged-emacs-devel@m.gmane-mx.org; Sat, 09 Nov 2024 17:45:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9oZi-0000en-Fk; Sat, 09 Nov 2024 11:44:38 -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 1t9oZd-0000dn-PF for emacs-devel@gnu.org; Sat, 09 Nov 2024 11:44:34 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9oZd-0000wv-7L; Sat, 09 Nov 2024 11:44:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=iL9y/zfTDTrQSEdhGQucowZyTFhAgb1gNremJVcXmac=; b=Fm/hkQPRWixjr0J1AfXj ukt/tw00XVa/sgZQcvLR52s9Yyrf57CowlMXtHCE+jY/nooAn4hTLpNgiEOlJDMAsutoGFQU3s6rh m7NC4NfJ/Yh7dlvkWUzYEen/FtJNxNAzuZjidlIzV8QIIN8QeXewejGZwMyXPHvkmCcvklxQ5kmW4 dpCVk2BVwLJsoJvFCFeIwPXlGqC3UsudSMUKBBrBFnnGBLqJ9/1pYcDRmv+BF2L1FibKi05+Cq25J p1dCwYueJc+ljf1pKNYK3t8QXVJ4AnT6/ItEo1l6w0mzg2hMnoIgWqa3n+WyJ7Phu8anxP2AwJKlT 4PNi7yRlNiLOAg==; In-Reply-To: (ams@gnu.org) 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:325340 Archived-At: > From: "Alfred M. Szmidt" > Cc: arthur.miller@live.com, emacs-devel@gnu.org > Date: Sat, 09 Nov 2024 11:33:45 -0500 > > (while-let ((run (some-condition))) > (message "running")) > > Do you expect that to evaluate (some-condition) once, then, if it’s > initially true, run forever? > > That is how it is described in the manual, so yes (some-condition) > should only be done once, and not every iteration. See (elisp) > Conditionals . Which could mean that the manual is wrong and needs to be fixed. > It can be convenient to bind variables in conjunction with using a > conditional. It's often the case that you compute a value, and then > want to do something with that value if it's non-‘nil’. The > straightforward way to do that is to just write, for instance: > > (let ((result1 (do-computation))) > (when result1 > (let ((result2 (do-more result1))) > (when result2 > (do-something result2))))) > > Since this is a very common pattern, Emacs provides a number of > macros to make this easier and more readable. The above can be written > the following way instead: > > ... following the various with various FOO-let forms, ending with > while-let. The above description actually supports what Yuri was saying, not what Arthur and you expect.