[Top][All Lists]

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

Re: Code for cond*

From: Stefan Monnier
Subject: Re: Code for cond*
Date: Thu, 25 Jan 2024 08:57:36 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

>> [1] I regularly convince myself that it’s such low hanging fruit,
>> there must in fact already BE a cond-let, and I go hunting for it.
>> The obvious interface seems like such a straightforward extension of
>> if/when-let, that there would be absolutely nothing new to learn:
>> (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))

Nice.  Would `var` and `dvar` scope over just the first branch or also the
other ones?
Technically, there is no reason for them not to be visible in the other
branches, so that's what I would go for.

Personally, I was thinking of a syntax like

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

with the intention of replacing `cond` without introducing
any incompatibility.


reply via email to

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