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: Sun, 10 Nov 2024 06:44:34 -0500 Message-ID: References: <861pzkmk5v.fsf@gnu.org> <5998bf4f-c35b-409d-9e76-d31ce037c8df@vodafonemail.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14664"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, yuri.v.khan@gmail.com, arthur.miller@live.com, emacs-devel@gnu.org, drew.adams@oracle.com To: Jens Schmidt Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 10 12:45:31 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 1tA6Nm-0003bo-OB for ged-emacs-devel@m.gmane-mx.org; Sun, 10 Nov 2024 12:45:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tA6Mw-0005Y1-RV; Sun, 10 Nov 2024 06: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 1tA6Mu-0005XF-RB for emacs-devel@gnu.org; Sun, 10 Nov 2024 06:44:36 -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 1tA6Ms-0000ar-VW; Sun, 10 Nov 2024 06:44:34 -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=A/AaZ3ZUMJb2s94zlNvp4Ihfi2DDuc5/hm6UTW8/H9s=; b=QBggFowOrQxZ DyP9dt43+Z3eNqaKYSq5dYZwJYZBCG+gjieuTlgk8anusqa5lDi4+UHfcgjUPSEdTygt9K7zFthpc CZSpqFW5ksKlhtY61KNwz6I09YvHlKUA6YNXb4RYmyNGg18JNxcoyFoYnkn0J/sNpguCinHOzsH5n QthAvRrpfKsFsxLMdEUu/jYMeaSSMjPfqqo6eL02FaBLN8YyIrc0QEDImviF0edenI7S4jzWFX6/9 61hFOELrPhquVbAuJO52Viq4ExJ5WFKPV1g/ra0oLtWF3qAVn3t1xJpnkyNOoCFUVMZ0i/ZYC2QAV gHh1Rl3r8upWhSuJ555x2g==; Original-Received: from ams by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1tA6Ms-0004zr-Fo; Sun, 10 Nov 2024 06:44:34 -0500 In-Reply-To: <5998bf4f-c35b-409d-9e76-d31ce037c8df@vodafonemail.de> (message from Jens Schmidt on Sat, 9 Nov 2024 21:02:12 +0100) 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:325372 Archived-At: > 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? I hope I don't miss anything important here, but I think the first two elements in SPEC of below `while-let' (while-let ((b) ((< b end)) (e (next-single-property-change (1+ b) 'erc--msg nil end))) ...) do not actually bind anything, they only test. The doc string of `if-let' has: Each element of SPEC is a list (SYMBOL VALUEFORM) that binds SYMBOL to the value of VALUEFORM. An element can additionally be ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ of the form (VALUEFORM), which is evaluated and checked for nil; ^^^^^^^^^^^^^^^^^^^^^^^ There is no mention of this in the manual, that only says that SPEC is like the one in LET*. The followiung, (if-let* ((b) ((< 1 2))) 'foo) Throws an error that B is not defined. Clearly this is not at all like LET*. So does: (when-let ((b) ((< 1 2))) 'foo) All these are described as "like if-let*". If this is useful or not is one thing, but clearly these macros try to be too "smart" and don't follow their own description of what they do in either docstring or manual. i.e. SYMBOL can be omitted if only the test result is of interest. It can also be of the form SYMBOL, then the binding of SYMBOL is checked for nil. I'd align such clauses like this: (while-let (( b) ( (< b end)) (e (next-single-property-change (1+ b) 'erc--msg nil end))) ...) to emphasize that.