[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
(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))
with the intention of replacing `cond` without introducing
any incompatibility.
Stefan
- Re: Code for cond*, (continued)
- Re: Code for cond*, JD Smith, 2024/01/23
- Re: Code for cond*, Stefan Kangas, 2024/01/24
- Re: Code for cond*, JD Smith, 2024/01/24
- Re: Code for cond*, Stefan Monnier, 2024/01/24
- Re: Code for cond*, Stefan Monnier, 2024/01/24
- Re: Code for cond*, JD Smith, 2024/01/24
- Re: Code for cond*, Stefan Monnier, 2024/01/24
- RE: [External] : Re: Code for cond*, Drew Adams, 2024/01/24
- RE: [External] : Re: Code for cond*, Drew Adams, 2024/01/24
- Re: Code for cond*, Madhu, 2024/01/25
- Re: Code for cond*,
Stefan Monnier <=
- Re: Code for cond*, JD Smith, 2024/01/25
- Re: Code for cond*, JD Smith, 2024/01/25
- Re: Code for cond*, Alfred M. Szmidt, 2024/01/25
- Re: Code for cond*, JD Smith, 2024/01/25
- Re: Code for cond*, Stefan Monnier, 2024/01/25
- Re: Code for cond*, Alfred M. Szmidt, 2024/01/25
- Re: Code for cond*, Stefan Monnier, 2024/01/25
- Re: Code for cond*, JD Smith, 2024/01/25
- Re: Code for cond*, Richard Stallman, 2024/01/28
Re: Code for cond*, Richard Stallman, 2024/01/25