From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: arthur miller Newsgroups: gmane.emacs.devel Subject: Is this a bug in while-let or do I missunderstand it? Date: Fri, 8 Nov 2024 16:25:12 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_DU2PR02MB10109418CE246C3FA269A0685965D2DU2PR02MB10109eu_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3430"; mail-complaints-to="usenet@ciao.gmane.io" To: "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 08 19:44:01 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 1t9Txg-0000lE-He for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Nov 2024 19:44:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9TxT-0001p2-Ov; Fri, 08 Nov 2024 13:43:47 -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 1t9RsK-00012G-6v for emacs-devel@gnu.org; Fri, 08 Nov 2024 11:30:20 -0500 Original-Received: from mail-am6eur05olkn2070.outbound.protection.outlook.com ([40.92.91.70] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9RsI-0004Ax-4I for emacs-devel@gnu.org; Fri, 08 Nov 2024 11:30:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B36D0GgDUyxqpnf/WgjtxZxSIaqtIEU7a0JTXhd2fGgHiR/Q431Ni0CXyZvvIU3rKgog6nMjNBYlfrELKTQOUV4JU50q4rIza0m0Ogyylf9g4fhjfmVnegY6xa4sj5R2eksO9Hlkkritss/glbcCU87speP8t9etabExGrR6oUHjp5yfHoloUCDghSu5CkdxVntcYx4O14WJ51+hPhIWsW2Yft9DN8//MJ/17hl20AqiaUMo8+ic/DpHqFqZoHK+MjIW1ZDaEVHlRsMpjl5xD+BA3FvPPrprU0DXfOLwL7LokwRp37vWCf7OANuvZF+56YCtytbkPnAmSdYrZnNhlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uwOouNaIigOQt/l2uNkSkYvSK8B2GNSOUPXtxtb5IhQ=; b=d4lWWEcL7hFpw+Wc65MfZy/SHeDWlBGmfBABJsx9/s7zPsRz2TuLDaJ4ubIElK+WpwzLEk/AU79gQkliItA5t2TcDHdDBBpkFCWaJu3OpeJjJqURlsw1w7b6tG4nOdzCyQFBPiWW8vr9h3La5X6eTzOQDHBAAHe4ZF3HmysIuhdIS6yM0H1rHAEfijRHcZhseCs6CJup/HBp4pfRdOAndjkcOwhkAXRlWPoVCXX1FOeJP4re2OBh10V9+cCUAUUjZM2wQUUygDt+ksMESY10qFLRLEeGdyxMXXcuiLwaX8x+fjaZ8zjdkRx0hXd1SmR2VIDULDLyTpB+JQBR4WggNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uwOouNaIigOQt/l2uNkSkYvSK8B2GNSOUPXtxtb5IhQ=; b=tamYnA7A7mYtCv7+RLUI+4sQWxvoGTJgXv6xLovHjwEeUGlGTMk/RBkbEmzhUcglaC2rZoxBv7ZpV77PhznghU+tLKkgfx2qOtHooj2vvXu7NLDtkwsBldIi3AQSt0EmWWM2qaxmYc2v9DVmj7D4eSbVbluvEpwJUIrkvIsrFWfYTNplZDbEDBLU60nNjQURzGGGW2Y9KOA2CdN3oTwOUUDMV7ifglv7EEwNcd9Aob7R6rbUCwf3tJGENfrFuoxvvoqsd75z0eQU31XoysYer26X78tSRiy9wfjjIN1tuAQo8jx3SkM4ZTYcRQMOCVgIXH6fgTzKqH03dcqDKNOZMQ== Original-Received: from DU2PR02MB10109.eurprd02.prod.outlook.com (2603:10a6:10:497::14) by DU0PR02MB9051.eurprd02.prod.outlook.com (2603:10a6:10:47c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Fri, 8 Nov 2024 16:25:12 +0000 Original-Received: from DU2PR02MB10109.eurprd02.prod.outlook.com ([fe80::f3c9:d4cb:290:d487]) by DU2PR02MB10109.eurprd02.prod.outlook.com ([fe80::f3c9:d4cb:290:d487%4]) with mapi id 15.20.8137.019; Fri, 8 Nov 2024 16:25:12 +0000 Thread-Topic: Is this a bug in while-let or do I missunderstand it? Thread-Index: AQHbMfbIoZNom93mHkmQsSTvSCnRbw== Accept-Language: sv-SE, en-US Content-Language: sv-SE x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DU2PR02MB10109:EE_|DU0PR02MB9051:EE_ x-ms-office365-filtering-correlation-id: 17beb4ed-60bb-4a00-a736-08dd0011eb74 x-microsoft-antispam: BCL:0; ARA:14566002|461199028|19110799003|15030799003|8060799006|8062599003|15080799006|7092599003|3412199025|440099028|102099032; x-microsoft-antispam-message-info: =?iso-8859-1?Q?CX6ftICislJ3gE3Vp6CMfO/7N4OReVR8ho3n6nM8bRG3qoLal8JggHYubj?= =?iso-8859-1?Q?olcCsuNZUN5pfTMPTacCGFA++VSYhqLV2tz1Ts5ppfuuPMtoF+zZF/2Ihh?= =?iso-8859-1?Q?vAoAZ4Tp+plIElyTDqw/SiQr3h5d67hL7DwnlecFZDvVN07V98OdD2xQmy?= =?iso-8859-1?Q?YC0IKNVvtKJ9P9L3hHHBJUw8kZCZ4yb5myAYOxtOUbixYNzFfAoOM5WFnH?= =?iso-8859-1?Q?xRX5elYiLFCgDvRbL8+alVzZ5Y5nSWUHt7DQBP3OIzA0/JTGYi7TDZGVVg?= =?iso-8859-1?Q?dbwwZ5MbPOqVGpe9MrByIX5J6HFoWw+f+/4dxMfpTsIW7XqhWpOxK0UTGk?= =?iso-8859-1?Q?B8UYLp4gERkdTzcGqFcmNeaRX0IltxBUCZ4VEqTNW8H3b3Qs86VWFi93dv?= =?iso-8859-1?Q?YF/xCCad00yRw5CKuW2Wvi4EFDXXIyXZb37FRShOkAsBXU0dC9pin23VsW?= =?iso-8859-1?Q?aXllcn3LngvPFSvrZt1M0rEsa8eRquq0RKLwWFiKwaQ6tzDtR94DAZb776?= =?iso-8859-1?Q?LTRtzSCkWxS3+WQyYn+NcBpOdWSWlLfKGfx+046c1waj/jThVzmfnClvqG?= =?iso-8859-1?Q?y2fdwNfrGN2XhiArurwu+fZEpSLZC3kTZo1P/DcV5s7zw4mm12X36CAKef?= =?iso-8859-1?Q?1LO x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?SBvSJ+AYymZkhdPpnR9D/PL05/ZIyhenKlHgsQEGsOE3ubwayYDb9YJqIz?= =?iso-8859-1?Q?ADFsx6NAo5leOQF5BeVyYYJxU9eIk5m/A7t2TZz02dpIHbotjuIii47hAo?= =?iso-8859-1?Q?Aa02ou0gFE4S2rV54dFEqbnWHDtxkjmsuMi13KVH+ClLYKcRU5SpU+sM3y?= =?iso-8859-1?Q?vEWeAJnCnfi7B7vq/3lR7n/lGdQWKCRLRmfgZfLvLa8ZMEeB7CAbiFJCgS?= =?iso-8859-1?Q?A2qhBNDm22V6zkdQlXxf+yOARriMAKrefQYPbMIfSltR+/2/Dqe6Gwe9s4?= =?iso-8859-1?Q?o9nB6RkBLDLekzuzQbjyQPro6ghgzywWrlu223eYSgHyOjD3UTd8hHFTJ2?= =?iso-8859-1?Q?vZVYS2UJMk6a3jltAOHKcRTRAuj3rJTTL8GoVkW5hkwInN5wJp8yQJXDpk?= =?iso-8859-1?Q?5VGphRNzFo49fCE0k1Ywzir9cT0mh8iN4iFV0GwLVRVa85Mw3Ec03uuCOU?= =?iso-8859-1?Q?ZVivVirN8UjfA9GMPgxUfHg3ZeVmPTrtIgz1Hzjwha/RYOBTueSKmhpv0p?= =?iso-8859-1?Q?0048clcyKN4KhzY97zePvuDU0JmtAFCjvrbJDLCVRo90ZQIC1WPK+xHB79?= =?iso-8859-1?Q?cDrl6rqVf7lKlPMYp2Y6EcnWWitahA1BVX3bHjMlPtYn4W3iAm44otSDY9?= =?iso-8859-1?Q? X-OriginatorOrg: sct-15-20-7828-19-msonline-outlook-12d23.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DU2PR02MB10109.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 17beb4ed-60bb-4a00-a736-08dd0011eb74 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Nov 2024 16:25:12.0949 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR02MB9051 Received-SPF: pass client-ip=40.92.91.70; envelope-from=arthur.miller@live.com; helo=EUR05-AM6-obe.outbound.protection.outlook.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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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, 08 Nov 2024 13:43:43 -0500 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:325306 Archived-At: --_000_DU2PR02MB10109418CE246C3FA269A0685965D2DU2PR02MB10109eu_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable (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 vari= able. I tooka look, but I don't understand why is it necessary to build while-let= on if-let. This simplified version did it for me: (defmacro while-let (spec &rest body) "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. The variable list SPEC is the same as in `if-let*'." (declare (indent 1) (debug if-let)) (let* ((bindings (if (and (consp spec) (symbolp (car spec))) (list spec) spec)) (variables (mapcar #'car bindings))) `(let* ,bindings (while (and ,@variables) ,@body)))) (progn (while-let ((run t)) (message "Running") (setf run nil)) (message "out of loop")) =3D> "out of loop" Or did I missunderstood how to use while-let in subr.el? --_000_DU2PR02MB10109418CE246C3FA269A0685965D2DU2PR02MB10109eu_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
(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 vari= able.

I tooka look, but I don't understand why is it necessary to build while-let=   on
if-let. This simplified version did it for me:

(defmacro while-let (spec &rest body)
  "Bind variables according to SPEC and conditionally evaluate BO= DY.
Evaluate each binding in turn, stopping if a binding value is nil.
If all bindings are non-nil, eval BODY and repeat.

The variable list SPEC is the same as in `if-let*'."
  (declare (indent 1) (debug if-let))
  (let* ((bindings (if (and (consp spec) (symbolp (car spec)))
                     = ;      (list spec)
                     = ;    spec))
         (variables (mapcar #'car bindings)))
    `(let* ,bindings
       (while (and ,@variables)
         ,@body))))

(progn
  (while-let ((run t))
    (message "Running")
    (setf run nil))
  (message "out of loop"))  =3D> "out of loop&q= uot;

Or did I missunderstood how to use while-let in subr.el?
--_000_DU2PR02MB10109418CE246C3FA269A0685965D2DU2PR02MB10109eu_--