From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.devel Subject: Re: Code for cond* Date: Thu, 25 Jan 2024 11:00:49 -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> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_33F56F19-030A-4EB2-9E05-0D5D47C31763" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15590"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Madhu , emacs-devel@gnu.org To: "Alfred M. Szmidt" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jan 25 17:02: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 1rT2Ay-0003kt-2w for ged-emacs-devel@m.gmane-mx.org; Thu, 25 Jan 2024 17:02:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2AG-0003oK-5e; Thu, 25 Jan 2024 11:01:16 -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 1rT2AE-0003mY-Ft for emacs-devel@gnu.org; Thu, 25 Jan 2024 11:01:14 -0500 Original-Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rT2A3-0006Dm-Pb; Thu, 25 Jan 2024 11:01:12 -0500 Original-Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-5ffcb478512so7459697b3.0; Thu, 25 Jan 2024 08:01:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706198461; x=1706803261; darn=gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=t2uxN+7P5tJq79N9u8loqLVfBoKuy1ipGVzlU5C2StE=; b=BI9sGcEv/uIKnM67zZyUi2m/H9ZOwgpRerdR6+WYEAfGBXQ2inf+IbLESxNdwE0QOR PpTmpL4S04oOMXwd9UJ069L7bztNyk30vjc0o35ADMWtvcNFmo3lAaFDoctqOBu5O68g u1+qGtzmbsUX+1PnA4ju5Mth8ENmT2L+slOy58DmCWlN6uPjGiGgFBTEYuOMawKqGdQm bxHr5J/jCehvnkV+6F8l3dSZmWa7FpWHjR9Luu3voO4CRfLOxzaWXVcBvsdPgf05ouiw csNGCulZvm+4H6cdCeBUBbXNL5IAuwal5joTIPeKP+MUZzzXw89fOw2Zh4lYb7FaipSc ez6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706198461; x=1706803261; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t2uxN+7P5tJq79N9u8loqLVfBoKuy1ipGVzlU5C2StE=; b=fE/ve1G6zePIH3LZIh2DyNgAMILbyFw4XOuusH/3quYIytwN/SFlbYsYepe4ZimwKo gdZPQ5Y96SX7fR3WXITs2LpSTuEDdb4jVSvPts1tgWLCvy7yE6+ttJ8B5GP3vGjqpiRH +xe2fNAD8Z+FiuycaTJ4oM0N1csCVqIOonUWaQZhFSX7mYvxAFdhqJDhRQms5halenKD K2BXMZPjTJjzMOVgIfSKAViuEmKLagtDSAp7EpUxqSRL6beUUHvZLvpkeBvRhhKACjSd OzWrCFw69ZcDrW6j6zQCuuGbbcruIv8XYj2a2sKe43KpH54K+rlUm3FvVk5rDxye8vGp jT9g== X-Gm-Message-State: AOJu0Yws3uXSsGOXIPZmndYfbtvtfMHp+U/W6I0Ex3FmQzq17cjyPig0 FomElYnE7kORqUdSkqEfEthmzRVuveJDW4FmZu/dPXfrg0xt/so9fYaD/sv+ X-Google-Smtp-Source: AGHT+IEVV2pbNgyii7uHSW4xIbjP8YDXZU+svTm/SK9hTl6Dt5wk3WxnefdKSbggEcAuYpDx9Rf7Xg== X-Received: by 2002:a0d:dfcb:0:b0:5f9:ca19:cb80 with SMTP id i194-20020a0ddfcb000000b005f9ca19cb80mr99401ywe.11.1706198460675; Thu, 25 Jan 2024 08:01:00 -0800 (PST) Original-Received: from smtpclient.apple ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id p189-20020a815bc6000000b005ff5222520esm729537ywb.105.2024.01.25.08.00.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2024 08:01:00 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3774.300.61.1.2) Received-SPF: pass client-ip=2607:f8b0:4864:20::1133; envelope-from=jdtsmith@gmail.com; helo=mail-yw1-x1133.google.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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:315373 Archived-At: --Apple-Mail=_33F56F19-030A-4EB2-9E05-0D5D47C31763 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jan 25, 2024, at 10:44=E2=80=AFAM, Alfred M. Szmidt = wrote: >=20 >=20 >=20 >=20 >> On Jan 25, 2024, at 10:17=E2=80=AFAM, JD Smith = wrote: >>=20 >>=20 >>=20 >>> On Jan 25, 2024, at 8:57=E2=80=AFAM, Stefan Monnier = wrote: >>>=20 >>>>>=20 >>>>> (cond-let >>>>> (((var value) >>>>> (dvar (derived-from var)) >>>>> ((has-the-right-stuff-p dvar))) >>>>> (cons 'correct dvar)) >>>>>=20 >>>>> (((foo value2) >>>>> (bar (1- foo)) >>>>> ((< bar 0))) >>>>> (cons 'incorrect bar)) >>>>>=20 >>>>> (t nil)) >>>=20 >>=20 >>> Personally, I was thinking of a syntax like >>>=20 >>> (my-cond >>> (:let var value) >>> (:let dvar (derived-from var)) >>> ((has-the-right-stuff-p dvar) >>> (cons 'correct dvar)) >>>=20 >>> (:let foo value2) >>> (:let bar (1- foo)) >>> ((< bar 0) >>> (cons 'incorrect bar)) >>>=20 >>> (t nil)) >=20 > And it perhaps goes without saying that the two approaches could be = combined :) =E2=80=94 >=20 > (cond-let > (:let var-for-rest value) >=20 > Is there a reason why using a keyword here? How would multiple > bindings be handled -- or is that what the two forms: >=20 > (:let foo value2) > (:let bar (1- foo)) >=20 > try to convey?=20 Stefan correct me if I=E2=80=99m missing the main point, but I think the = difference motivating a special form like (:let =E2=80=A6) comes from = the desire to establish bindings for all the rest of the clauses, and to = make it clear you are doing this. I don=E2=80=99t know the right way to = handle that (or how important it is). The proposed cond* has that = capability. My cond-let idea has somewhat different goals, akin to a = short-circuiting group of when + when-let=E2=80=99s. Its clause syntax = is just a straightforward copy of when-let; hence no new syntax to = learn. --Apple-Mail=_33F56F19-030A-4EB2-9E05-0D5D47C31763 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jan 25, 2024, at 10:44=E2=80=AFAM, Alfred M. = Szmidt <ams@gnu.org> wrote:




On Jan 25, 2024, at 10:17=E2=80=AFAM, JD Smith = <jdtsmith@gmail.com> wrote:



On Jan 25, 2024, at 8:57=E2=80=AFAM, Stefan Monnier = <monnier@iro.umontreal.ca> 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 :) =E2=80=94

  (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? 

Stefan correct me if I=E2=80= =99m missing the main point, but I think the difference motivating a = special form like (:let =E2=80=A6) comes from the desire to establish = bindings for all the rest of the clauses, and to make it clear you are = doing this.  I don=E2=80=99t know the right way to handle that (or = how important it is).  The proposed cond* has that = capability.

My cond-let idea has somewhat = different goals, akin to a short-circuiting group of when + = when-let=E2=80=99s.  Its clause syntax is just a straightforward = copy of when-let; hence no new syntax to = learn.

= --Apple-Mail=_33F56F19-030A-4EB2-9E05-0D5D47C31763--