emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code for cond*


From: Alfred M. Szmidt
Subject: Re: Code for cond*
Date: Thu, 25 Jan 2024 10:44:52 -0500



   > On Jan 25, 2024, at 10:17 AM, JD Smith <jdtsmith@gmail.com> wrote:
   > 
   > 
   > 
   >> On Jan 25, 2024, at 8:57 AM, 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 
:) —

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]