From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: [External] : Re: Better documentation for non-binding clauses of if-let and friends Date: Tue, 12 Nov 2024 00:26:07 +0000 Message-ID: References: <86msi69icp.fsf@fastmail.fm> <861pzh1j0u.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19214"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Alfred M. Szmidt" , arthur miller , "emacs-devel@gnu.org" To: Joost Kremers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 12 01:27:13 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 1tAekS-0004kA-Kz for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Nov 2024 01:27:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAejk-0003Uv-CJ; Mon, 11 Nov 2024 19:26:28 -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 1tAejh-0003UT-46 for emacs-devel@gnu.org; Mon, 11 Nov 2024 19:26:25 -0500 Original-Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tAejb-0001LY-Dl; Mon, 11 Nov 2024 19:26:22 -0500 Original-Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ABMu03x016749; Tue, 12 Nov 2024 00:26:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=OXKPaMQPK3T8GNk/LwvRM8Cw6bXKethU+XqRmjOF+XE=; b= a5MvzwFfUj8/FK9oB5DMYDMLeIiy6YWa0rN03dJlfICsrrQDI0iFr1rNbht5F6wW ZChVSb0w5CeOlfB1EOLUTXTx0inydXo2WyumLIpcyiuwQoqbqHLqSOfiOQ81YBbq OkXtJcZ7Em2FNIs39tvmYhbVwCKHeP0E1M3Q0ywhJUjsl0J5e7kQMECS8LbN993K iS7LLTV86/BG9ue44Lwst6E9JfnS9QTNWZcT0akwO+4ymGe7hFdGwiVrmpf8qK39 zpmUAnNt7QwdOsDeg06M2fD1jWUWBAWOZIe2rQBn1pd/4x7FhgBAnFPfiph2KhJi GjmQCCrqqEW3QNCyWq7HGg== Original-Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0n4ubsf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 00:26:13 +0000 (GMT) Original-Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4ABL4fwt034370; Tue, 12 Nov 2024 00:26:12 GMT Original-Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2046.outbound.protection.outlook.com [104.47.70.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx67j6j0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 00:26:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YF0q2/rg2xUnVzT6Ki/Zypioy3PVc+oGw1vd6qNmNKS+XaatBlDXkJxShHsvub7DgCZ7RSh7pijDNjM6LRLTc0uORAGQ2LrZzxu2hGzlQ4+L+s0NYFS/rpHnO2EkvikcqyXnjEY2L32ZbZHheEr8WG054KSoJB3IrGea0JYiZ6im41eTPyw//NMgG3FI8yiM62KUWESlBUhpxhmE4bBUQQwQu3xW2Pk1gKQnNWf+98QyEJtOhUdCUhYRCbDS/vjFgcZrGcQmO8fvtGNMSkH4Y4tg89JD6OyKhWl2FLXiszuCrUzm9zO7bYWT0oEGw6AzQ6qyskcmnjufCeRfB17EiA== 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=OXKPaMQPK3T8GNk/LwvRM8Cw6bXKethU+XqRmjOF+XE=; b=A8G9dalwMmWuO1y5B9NwfPZ0qchKgs/TnGab+WQxZnGhr8CN5jxtXJTQWvviKfM2oJ+uUZwl5sQrSA4rI0PC2exwsdcpSiVnhaaCgAo7hlJO0/Pi01sZwZaX3SEDOdYp8pr2NJWPh0JdlH+qXC/AmvchRS6oMMc7tpX/w+UAJzqfayP3rI9zfBwEBnKlnW4i3ozGXqbCPxOsHMJuyVvB3PVX1mEchLuKHtPohr+vpuIEdhof6g7lkZA9UG7zeGypG/ULMowju5ObHidnm/336tPFabO/r8uUJZacvSy9djnRY50HY2gSPbpMLksQ2Nbjqj3tWamT1U7TTQ2p3cbEpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OXKPaMQPK3T8GNk/LwvRM8Cw6bXKethU+XqRmjOF+XE=; b=ITXB0iaqf7I9EPvJ+8YS0nwZb4thodmpwpXmSP5BH1ZtIIwja0BU5e0dnmt8iaaL9By2qGaqmndr5Obj+QRDXWB3asKw17umQy8Cg+Q1AIZEgXNE0EpVoHYsyK+BdfLUHDVBjOhz7b4aHOIvT+2PCnZqaIw9TAp5L8d1CJdIPsg= Original-Received: from DS7PR10MB5232.namprd10.prod.outlook.com (2603:10b6:5:3aa::24) by PH0PR10MB4487.namprd10.prod.outlook.com (2603:10b6:510:40::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Tue, 12 Nov 2024 00:26:07 +0000 Original-Received: from DS7PR10MB5232.namprd10.prod.outlook.com ([fe80::8303:658f:14f8:2324]) by DS7PR10MB5232.namprd10.prod.outlook.com ([fe80::8303:658f:14f8:2324%4]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 00:26:07 +0000 Thread-Topic: [External] : Re: Better documentation for non-binding clauses of if-let and friends Thread-Index: AQHbNIxF2YDaSWB5Jk2/l/qcN4uzCLKyu1qA In-Reply-To: <861pzh1j0u.fsf@fastmail.fm> Accept-Language: en-US Content-Language: en-US x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS7PR10MB5232:EE_|PH0PR10MB4487:EE_ x-ms-office365-filtering-correlation-id: 41dc141c-d9ff-4d3c-325c-08dd02b099e5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?dZTra+m574pL4GQF9kmm5gsBEYvEAsQvL4eB36ESqpl74yJkgPmIpHJ0pO?= =?iso-8859-1?Q?ivT8TSPeXCOMPpgWkvUCgvbPZdT5XxY2D+lCrkl7nNVY/ywvcM9cIbMdn7?= =?iso-8859-1?Q?tvSbqLo4VqMrVR5izYC+wxuC/R5snVmSnD2f5FfBcp0dtj7o/ZwYsYBzYf?= =?iso-8859-1?Q?CEaVfOlbYAhSOyMVWmWMcT75bVO/mAFnp2OHGGUOsEjvNsIcZClFW+8uuw?= =?iso-8859-1?Q?vU7vAwOz98v/p8TcVGTZISkRa8yV3Z2EfR/gyhoyiYVLCvZ/en/ERBLimq?= =?iso-8859-1?Q?x95ZtM13UL26U+KS6Mn0uM2F+T5Gzkcyg1tMYq0+XGj031C2ADdH7+nSfA?= =?iso-8859-1?Q?IOGto5fS/AOtFaZHZd2QnVG0SrZaK6Vca7JpZ/J7buloRmP2c124Hdy2FE?= =?iso-8859-1?Q?1JqG6w15Hhgd22+VrOvWYaTuuFMaXDG9bw/DtHIn0V1zIN5s3hLk4JlN4P?= =?iso-8859-1?Q?S5dTA7MW/CFn0F90FwNDFDYm4CJTPmbqkp0hCj833CTX1GAiFTWgiYnor+?= =?iso-8859-1?Q?YHfqmeN1M50sx1eEtYwZ4hUYKbywy6LSoHGCHDWLuc5AmHUSnsdU795s98?= =?iso-8859-1?Q?nRudXh0RzrRVvEn7aj2YEoNKLLWYFuOc8AkSU3g7Mwy5y5J7FLcNr74p7s?= =?iso-8859-1?Q?hqQ x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR10MB5232.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?at55pRr2DAkTu1SC+tz93V0sxm2JO8Xwfwy6qC17nTMc/blj8JRwI3IVex?= =?iso-8859-1?Q?GmajRGH576S8GZ8bLhEEyK0mG5G6nhrmzn5XiHnmDkk+J0XAAQTKNllkjr?= =?iso-8859-1?Q?mxP3QykTCDSEuABXcb2LLp4LS8eAH3YUz5WAlOgMQ6h13EM+hIt9QXCGuX?= =?iso-8859-1?Q?Gd6MRyxP6ZOXCpDUymvn+sAbF0ZbQpnz2+NVv0KMnURwdEOY5B7+h1O/jX?= =?iso-8859-1?Q?vQQSwsNSJ4z5F0WUguubIuHnjlmYzTN6gsILp4gauEhQI3pK6YhDh1tk0e?= =?iso-8859-1?Q?qYX76fffMtYUO06/WLHOmg5WqK3LC2bEKEvO+nkOarsnLLURSg7GvIrHTl?= =?iso-8859-1?Q?AZQ2CSfhk/qZ872zYNWLlvawX3ZfofpIAm55EVm2fL9x7CWApNbidT09Wk?= =?iso-8859-1?Q?kS6CZd8BSdIIZDGeanw4L20XM7dCCE3sP3Rom8HDzV+xJEc89VOkWApWEK?= =?iso-8859-1?Q?Pxu7LqGTvkljV7hUwxF3ClCZHZUOnOe/+4CCuZ5NScknaO2Z3taMfw9qh4?= =?iso-8859-1?Q?H86XcJgQO3ElgmwEZ3CucxbBeafMhLr+6Go1b97xMmOzWkJbOr91ugzOm4?= =?iso-8859-1?Q?ugdtXr2yZplTHF6JQ4dL/10dURbGrbDWXWZISeP1ma/PBozdd/OLA2vPqO?= =?iso-8859-1?Q? X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6M3hNe1RkahCKKTL3kHUP8/nXCYrmiCEimw6qKRmJZllKW3GkjGtwDxEMKl++YJqsQKEPloAilcym+DSaLU8MQDUMfEWwcs5bKf0TNEPmYjiwh6KARcDiU7PXHjTWX3j4A0MMBXWbWekViZN92/ciJyObJ1NPfwdkUHpkWB0bT37pjTSqNe0ecE9MQ3xYI0sRMWmWnIQEhN42By9IXnqYJpD6BtRicKOnovsploZ92mQ5gFG67BMz907niZG+YB6vJb0PLf1b4j8HYUlbMs7LRylJ7UZssR9Bg0kOK8wGc0ox7Qq6uBuNKHuoSWov8aa1QmHOSkc/duEQD/OCPQVtSB5PmTDrSgOGap+50Hw0BV0v649PcSa4056tDDovCxD7iKdXL24QzBlGYnvNKHskwndA0Bl4cFb4w0OEo3ajJIcplFdznWw6hMYfbYga0UncsInm8n8ve23Bk2ZqOrTBq6m+5Ur7CSx3OvQEHgJL2Hdce+9MU19D/wqccwbpNXB8p/PX2Ng4KrjVg7hNsdFQUsmCsPs97qHyrST3QRZ7QNZpJAlOiWUlKGkkdzD/rnw/K0rC2NqEKSUF3xyHVNNhejV7MVrqC5dTP9eEQrtqhQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5232.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41dc141c-d9ff-4d3c-325c-08dd02b099e5 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2024 00:26:07.5356 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OfBHEd2vGky6yUUqhFagwzBgc8hHl0/z4Pt/ghZ7eAfW2z3849Dw7Dcm8NP+/mi9uQzPPkfz+cCRpIokd9lpiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4487 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-11_08,2024-11-08_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411120001 X-Proofpoint-ORIG-GUID: qryN6IPXXZ9FLWh-0nyXtYOiBd21t7W- X-Proofpoint-GUID: qryN6IPXXZ9FLWh-0nyXtYOiBd21t7W- Received-SPF: pass client-ip=205.220.165.32; envelope-from=drew.adams@oracle.com; helo=mx0a-00069f02.pphosted.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:325415 Archived-At: > > (let*((open (and (parsebib--char "@") ^^^^1 > > (parsebib--keyword '("string")) > > (parsebib--char "{("))) > > (definition (and open (parsebib--assignment))) ^^^^^^^^^^1 ^^^^2 > > (s (and definition ^^^^^^^^^^2 > > (parsebib--char > > (alist-get > > open '((123 . "}") (40 . ")"))))))) ^^^^3 > > (if s > > definition ^^^^^^^^^^3 > > (signal 'parsebib-error > > (list (format "Malformed @String definition at position %d,= %d" > > (line-number-at-pos) (current-column)))))) > [...] > > > Beauty and clarity are in the eye of the beholder, of > > course. YMMV. >=20 > Yeah, I'm afraid I prefer the `if-let*` version. NP. Les go=FBts et les couleurs. > IMHO it more closely > reflects the parser grammar rule; it avoids unnecessary repetition of > variables (`open` and `definition` here) and the `and` forms that I feel > just obscure what's actually relevant. It avoids one repetition each of vars `open' and `definition'. Those occurrences make explicit the `and' dependencies implicit in `if-let* (necessary/relevant dependencies). This is your if-let*, with space separation of bindings from conditions: > (if-let* (( (parsebib--char "@")) > ( (parsebib--keyword '("string"))) > (open (parsebib--char "{(")) ^^^^1 > (definition (parsebib--assignment)) ^^^^^^^^^^1 > ( (parsebib--char (alist-get open '((?\{ . "}") (?\( . ")")))))) ^^^^2 > definition ^^^^^^^^^^2 > (signal 'parsebib-error > (list (format "Malformed @String definition at position %d,%d" > (line-number-at-pos) (current-column))))) Implied and-ing is all the if-let* gets you, at least in this example. At the cost of a loss of obvious distinction between binding and use occurrences. I guess your parser grammar rule (not shown) just has the (parsebib-*...) conditions as literal match patterns, and it has `open' and `definition' as nonterminals. (Or maybe `definition' is a terminal, since you return that.) In any case, you said you didn't know what an "equivalent without `if-let*` would look like". So I mentioned that `macroexpand' has the answer. And the answer isn't very complex. In this case, at least, it just makes the and-ing of binding dependencies explicit/clear.