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: Re: Is this a bug in while-let or do I missunderstand it? Date: Tue, 12 Nov 2024 03:36:11 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_DU2PR02MB10109920A011E7677B5C4BD8C96592DU2PR02MB10109eu_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10049"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" To: "joostkremers@fastmail.fm" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 12 12:48:28 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 1tApNk-0002XH-1b for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Nov 2024 12:48:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tApMv-0003jW-0W; Tue, 12 Nov 2024 06:47:37 -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 1tAhmL-0003u8-Mq for emacs-devel@gnu.org; Mon, 11 Nov 2024 22:41:21 -0500 Original-Received: from mail-vi1eur05olkn2042.outbound.protection.outlook.com ([40.92.90.42] helo=EUR05-VI1-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 1tAhmI-00030b-Eq for emacs-devel@gnu.org; Mon, 11 Nov 2024 22:41:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eaWEHVVMTn2b9jpyWQABL0ui4QFtlSXgxb5LUts9BFve5ybc+H+t90/tMrRJ1BBYDiqpxX0aGPsoadDOtXsO9A2zCl2liWM8nr967orsBcdGYo0CjyTbBL7qTZ9j0MF5mg2SAM3R+uTfHyjnmFGDP4pMUPBLQod+mZoqf8gj4DyHQP1C4U9D5oWoHMwKcrV/LKOwfmn7GCW+OubPBqItrVmuo3MoeK2CEaZlkKLQmyIj0d89cn33tpaVYd/pD+001XXGdApqp5kL7q7T/exxkkfU/1a9RyFCsP7yYGInzsItnBkQzScx+BAD4FXHOuzhNCGRGMs4OZk7jeWQJQlckA== 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=V0NV/Sqy2Iuqa56ZiiMOo7Kp+l0vT15hZ8Qg6+B9r6k=; b=HorA6Ugb1GSVdPUn+plch4bAxgnHz6SdS/qW79nJINkLm0cAiZQ6tP1+WisXPq+VSWNWHFRQWH77f85mU8vMRuYtcg/6OayICYIE6ePTiAFf5VzDUWC0GMIVdriC8Ke5D6lB/wwYmDtrPcvx2QsdBk6eNqJZQZtZwDFxbksXkN0MxB6tDUX8lIHtre+3D2WPwss67R27xERExc7MHqw7dDMlx1bd5ZllAQn7Sz/F/2Huh+eW7OZX8aEBS2gRNS3mdefIdm9PPq3zeU0T10Zd2uzwtibQe9Fc9BZB8MZ+5HZvHwoEYYiKrkdVBaats2cud31sq+UQoCngGEHdm1v84Q== 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=V0NV/Sqy2Iuqa56ZiiMOo7Kp+l0vT15hZ8Qg6+B9r6k=; b=lBHgYphINdRkMAgcTgfB3t70zcDgVcHscX0WpsdTunpPdOU8/LEPbqMKzbyyMuPAYjqyXPDcic8MN7MfGDVhEzBJaYEQ19oV8xhhssmgF91bi0q1MnMAXfWjfxs6URG4hjwfUp7KKasRAn/0vXcl6ePkhke+WDIb/cVfzRcDA7U1gM0kTGz13T9Fc2rVmVVXVLvaDTd265gUqwzxfO6jVHVwukFb+L3NR+yQOTN3RFBsAqOehE0NwM+M5PA43PQMuNyPonjhomLzqeL+T799wOCcFakPap3BNUzy3+MXdjlGaRlqjR5xjaLstU5c0kUDTaxr3wcDJahMy2BtvImppg== Original-Received: from DU2PR02MB10109.eurprd02.prod.outlook.com (2603:10a6:10:497::14) by AS8PR02MB7269.eurprd02.prod.outlook.com (2603:10a6:20b:3b0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Tue, 12 Nov 2024 03:36: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.027; Tue, 12 Nov 2024 03:36:12 +0000 Thread-Topic: Is this a bug in while-let or do I missunderstand it? Thread-Index: AQHbNLPcVlAnXa0EXEGtTDbNNiR8rg== Accept-Language: sv-SE, en-US Content-Language: sv-SE x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DU2PR02MB10109:EE_|AS8PR02MB7269:EE_ x-ms-office365-filtering-correlation-id: d846e1a8-718a-41e8-7879-08dd02cb2778 x-microsoft-antispam: BCL:0; ARA:14566002|7092599003|15080799006|8060799006|15030799003|8062599003|461199028|19110799003|440099028|3412199025|102099032; x-microsoft-antispam-message-info: =?iso-8859-1?Q?GrKSWieqme4W8ouAMO3OA0wZbMBoQ6KfiBv6xsXMuEt7qhM2SphmEpWSlB?= =?iso-8859-1?Q?bVW6OUBw0RnD4DRyEMYP/LpzEmqTIP68yS0NwSnFY3guL1ODcwKyNrzzxi?= =?iso-8859-1?Q?5nULfO3XUnp5eWsMiqlp1Pl/T9KK59qVEp3YZcs2NYY85+eObiiTNrRZig?= =?iso-8859-1?Q?REpGbM8ZyqkwGWckIWifnj+G5f3tAmhgeQkhTP2Ta65kR70wpM+i8P8Da+?= =?iso-8859-1?Q?fa2Evh5lfxp31tY+KF/te+3Do03NSvDmkXkzw3wh41M3JHxFGR9OYph3+i?= =?iso-8859-1?Q?YTVvtM8x+a0YmM7U0qxdEvJYfDCk15a4qv3AwzFlQb1GThZXeGHIdEmuZ7?= =?iso-8859-1?Q?nNQyUH/aTIV3quEsDnApNWejVtdFd1nXqT85clWXyTCpQotmLJpBwFfIZL?= =?iso-8859-1?Q?IeOSlkPQWOxyCmpIDtbUnJG7y/fXMLNlnGU0AUmJzstPFo9TAbdwWna4E4?= =?iso-8859-1?Q?4xcMoWy22M6/DrOn2KKVYBxJfhhthFHfNm5hB1QhR9qdEobXT/DmXPOh1r?= =?iso-8859-1?Q?xfqY0jBvcILOAXZOuqBbHj6vWBx8poCp256aYyX8L8rL6znrakUMc+jcMU?= =?iso-8859-1?Q?VsYORjCi2qiRL0pGkEvtxu4GryDdkrinDCJuVXpNsMuS0AIHw/gnq6gRkS?= =?iso-8859-1?Q?56H x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?6wDfSq4H79R87wiy5YPTBmMY/LhZpGH1TNGr8jxgzDUukwQ+QnDUZ5QWpN?= =?iso-8859-1?Q?4AZfSFHiw73BERjRA4vdF3aPXE+iw1WyMrjVnJsF6aFMspsxuaKP+P/b9y?= =?iso-8859-1?Q?SFl1QqLOYwqhuNIdZDAkZBgCyP09Frjj8IVe75teIYGagcdADym4fEWroh?= =?iso-8859-1?Q?aNbRVm/bXg5EYQhjLhKGYIp7c9CIDfsiM+hI4YTTl+WHsi9d+kA21AA833?= =?iso-8859-1?Q?h+pYIknjVpyOALh4HKPKqo0PDL3RRYV3uwOP2dPT7PM2PEvzme1UFxLXIO?= =?iso-8859-1?Q?dN9XNAFeh2WlHYj678LKjYH7Lpw0u2uUr1GOmlj/ID6X4s0+SxuGhbOM8U?= =?iso-8859-1?Q?7buxVagHkOTQgSdS0Vj1IEdks9PKkBYf4GE7bfzVDrNAyAQFou91Ge+69L?= =?iso-8859-1?Q?xFxJcFsJAmImpk3dIV2cxA6puJNGQ8KG3efvMAbroXVn+z5k+ehnPHFtO9?= =?iso-8859-1?Q?fA2Wq+RKjOJW1lw0DlcQbXzyx1HzSIenoVWSqHQUjnCOsvDeYq7zoUsvtT?= =?iso-8859-1?Q?jwv4OTlyOdhVASGPcUOadUSEhtBSv8Oq/Ssml9XqSJEfpmP7vXrBWb7IR0?= =?iso-8859-1?Q?5vU+YnYHPSA2LcbA4wnf2Wg3foDxSm2IhIpWLI76SfN3b8JZPNObhJN0Q1?= =?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: d846e1a8-718a-41e8-7879-08dd02cb2778 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2024 03:36:11.9796 (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: AS8PR02MB7269 Received-SPF: pass client-ip=40.92.90.42; envelope-from=arthur.miller@live.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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.671, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: Tue, 12 Nov 2024 06:47:34 -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:325421 Archived-At: --_000_DU2PR02MB10109920A011E7677B5C4BD8C96592DU2PR02MB10109eu_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable >+@code{while-let} replaces a pattern in which a binding is established >+outside the @code{while}-loop, tested as part of the condition of >+@code{while} and subsequently changed inside the loop using the same >+expression that it was originally bound to: >+ >+@example >+(let ((result (do-computation))) >+ (while result >+ (do-stuff-with result) >+ (setq result (do-computation)))) >+@end example >+ >+Using @code{while-let}, this can be written more succinctly as: >+ >+@example >+(while-let ((result (do-computation))) >+ (do-stuff-with result)) >+@end example >+ >+One crucial difference here is the fact that in the first code example, >+@code{result} is scoped outside the @code{wile} loop, whereas in the >+second example, its scope is confined to the @code{while-let} loop. As >+a result, changing the value of @code{result} inside the loop has no >+effect on the subsequent iteration. >+@end defmac The scope of the let-binding is the same in both. The crucial difference is that in the first example, the user have control over when and how 'result' is evaluated. The user can for example do: (let ((result (do-computation))) (while result (do-stuff-with result) (setq result (do-some-other-computation)))) Whereas in the other example, the code is automatically generated to pass in the original condition calculation, and the user can not interfere with the computation of the condition. --_000_DU2PR02MB10109920A011E7677B5C4BD8C96592DU2PR02MB10109eu_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
>+@code{while-let} replaces a pattern in which a binding is established<= /div>
>+outside the @code{while}-loop, tested as part of the condition of
>+@code{while} and subsequently changed inside the loop using the same
>+expression that it was originally bound to:
>+
>+@example
>+(let ((result (do-computation)))
>+  (while result
>+    (do-stuff-with result)
>+    (setq result (do-computation))))
>+@end example
>+
>+Using @code{while-let}, this can be written more succinctly as:
>+
>+@example
>+(while-let ((result (do-computation)))
>+  (do-stuff-with result))
>+@end example
>+
>+One crucial difference here is the fact that in the first code example= ,
>+@code{result} is scoped outside the @code{wile} loop, whereas in the
>+second example, its scope is confined to the @code{while-let} loop. &n= bsp;As
>+a result, changing the value of @code{result} inside the loop has no
>+effect on the subsequent iteration.
>+@end defmac

The scope of the let-binding is the same in both. The crucial
difference is that in the first example, the user have control over
when and how 'result' is evaluated. The user can for example do:

(let ((result (do-computation)))
  (while result
    (do-stuff-with result)
    (setq result (do-some-other-computation))))

Whereas in the other example, the code is automatically generated
to pass in the original condition calculation, and the user can not
interfere with the computation of the condition.
--_000_DU2PR02MB10109920A011E7677B5C4BD8C96592DU2PR02MB10109eu_--