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: Code for cond* Date: Thu, 25 Jan 2024 10:44:52 -0500 Message-ID: References: <1AD5807F-91F7-4B92-BCB0-D0FEA904A75D@gmail.com> <67B51664-352E-4EB1-AE17-6D571999FDDE@gmail.com> <4B3E3A7E-677C-43A2-92B3-562E99A8B897@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7538"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, enometh@meer.net, emacs-devel@gnu.org To: JD Smith Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jan 25 16:45:39 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 1rT1v8-0001p8-UH for ged-emacs-devel@m.gmane-mx.org; Thu, 25 Jan 2024 16:45:39 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT1uX-0005pq-9t; Thu, 25 Jan 2024 10:45:01 -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 1rT1uU-0005pZ-Jw for emacs-devel@gnu.org; Thu, 25 Jan 2024 10:44:58 -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 1rT1uU-00078I-3Z; Thu, 25 Jan 2024 10:44:58 -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=pW+laTFWH5rjfeMTHz+KCp5accIiUccLWyqAtoWJ+nc=; b=N8DOgH814u7o BqWJGqIHubUbzYLB4QhQKOEdQYx/wffl4aHPDB9Ih0VGp6Q7rMnhOAQT1o1DwOBFGSxKvv4gy5fh6 VYgsI4WHwSyo1yf2CIhmwyQ+R91hY+FSBVB/EKfEzIqF1jTE14GydewQC7iuY8db0WmaWx5JhYEVf wLVgj1HxzyStXKxTE3hkE9mKfwKBq79+1i104Bll84gU/hN4LxJk6TM6K+Es/1a0OVuEqWJNBH2c9 OsOgg8s2LCDncePdj+iYDDPKTJnANDEO5M9zHM2E7kWq+RdJ+Pkh7qLpiziS/cDtjgzZcaJzAS9h/ Ja+MrCD9CI6LntOYicRV1Q==; Original-Received: from ams by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rT1uO-00026S-4q; Thu, 25 Jan 2024 10:44:57 -0500 In-Reply-To: <4B3E3A7E-677C-43A2-92B3-562E99A8B897@gmail.com> (message from JD Smith on Thu, 25 Jan 2024 10:37:38 -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:315367 Archived-At: > On Jan 25, 2024, at 10:17 AM, JD Smith wrote: > > > >> On Jan 25, 2024, at 8:57 AM, Stefan Monnier wrote: >> >>>> >>>> (cond-let >>>> (((var value) >>>> (dvar (derived-from var)) >>>> ((has-the-right-stuff-p dvar))) >>>> (cons 'correct dvar)) >>>> >>>> (((foo value2) >>>> (bar (1- foo)) >>>> ((< bar 0))) >>>> (cons 'incorrect bar)) >>>> >>>> (t nil)) >> > >> Personally, I was thinking of a syntax like >> >> (my-cond >> (:let var value) >> (:let dvar (derived-from var)) >> ((has-the-right-stuff-p dvar) >> (cons 'correct dvar)) >> >> (:let foo value2) >> (:let bar (1- foo)) >> ((< bar 0) >> (cons 'incorrect bar)) >> >> (t nil)) And it perhaps goes without saying that the two approaches could be combined :) — (cond-let (:let var-for-rest value) Is there a reason why using a keyword here? How would multiple bindings be handled -- or is that what the two forms: (:let foo value2) (:let bar (1- foo)) try to convey? This feels like stabbing your eyeballs with a rusty nail and pouring salt ... The first suggestion was much nicer, and clearer. (simple0-using-var-for-rest body0) ; a normal cond-like clause (bindings1 body1-including-var-for-rest) (:let another-var (some-function var-for-rest)) (bindings2-using-another-var body2) (bindings3 body3-using-another-var) (t fallthrough-body))