From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Alfred M. Szmidt" Newsgroups: gmane.emacs.devel Subject: Re: [External] : Re: Is this a bug in while-let or do I missunderstand it? Date: Sat, 09 Nov 2024 13:18:41 -0500 Message-ID: References: <861pzkmk5v.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25246"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, yuri.v.khan@gmail.com, arthur.miller@live.com, emacs-devel@gnu.org To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 09 19:19:02 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 1t9q33-0006OV-8q for ged-emacs-devel@m.gmane-mx.org; Sat, 09 Nov 2024 19:19:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9q2l-0008Gg-QE; Sat, 09 Nov 2024 13:18:43 -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 1t9q2k-0008GX-UT for emacs-devel@gnu.org; Sat, 09 Nov 2024 13:18:42 -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 1t9q2k-00025y-4k; Sat, 09 Nov 2024 13:18:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From: mime-version; bh=nfkqzcePmz22EqMZ/zQW+7nZzDuPzkX8J5WoTeqh7XA=; b=lhCDXl6OMyvs w4H+5jv2GEzkpfVak/QrP46Tfm5q0Q+XZyCYlfhoEzkaeyrus/MTr6r089o39D9IyL0RPVrDGrbx0 gPUua2e0BJ9HXBBc/GS9m0UG9o/H05vBhUSAEFprNRzaozdZocGnIjzSSYf9u9GySXVoTpBhylZHO vdJS1RbUUvT7HwSKW1Wreg2z9v7KIfNwVUw3IYmSEFuwNvA9Lvdo+iO/dBHx9FQwld4nnL1MlNofr vAeqYtN4l0YjUQHXa+jiauLEENubTXt9ETJQrn22wvMI5G7pvtHDh0OnbFp9NM5aKjIJANPZ4KbH7 8dCS2IAhLVJWigxHsfr19A==; Original-Received: from ams by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1t9q2j-0000iC-M3; Sat, 09 Nov 2024 13:18:41 -0500 In-Reply-To: (message from Drew Adams on Sat, 9 Nov 2024 18:07:28 +0000) 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:325346 Archived-At: I'm not saying no one should use, or Elisp shouldn't provide, if/and/when/while-let[*] thingies. I'm just saying (1) I don't find them helpful, personally (I don't use them), and (more importantly) (2) if we provide them then their doc needs to be very specific about what _exactly_ they do, and when (if not also how). Agreed. I was looking of the usages of WHILE-LET in Emacs, and each time it is used it is quite confusing. For example this: (while-let ((b) ((< b end)) (e (next-single-property-change (1+ b) 'erc--msg nil end))) (save-restriction (narrow-to-region b e) (funcall fn)) (setq b e)) If the bindings are to be reevaluated on each iteration, shouldn't B always be NIL, and that it would end up with (< NIL end) would be on each iteration causing an error? How can (< b end) even be a spec binding here -- shouldn't that be an error? The exapanded code looks like this: (catch 'done39 (while t (let* ((s (and t b)) (s (and s (< b end))) (e (and s (next-single-property-change ... ... nil end)))) (if e (progn (save-restriction (narrow-to-region b e) (funcall fn)) (setq b e)) (throw 'done39 nil)))))