Sujet : Re: else ladders practice
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 06. Nov 2024, 08:26:25
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20241105173408.11@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-11-05, Bart <
bc@freeuk.com> wrote:
On 05/11/2024 20:33, David Brown wrote:
On 05/11/2024 20:39, Waldek Hebisch wrote:
David Brown <david.brown@hesbynett.no> wrote:
On 05/11/2024 13:42, Waldek Hebisch wrote:
Bart <bc@freeuk.com> wrote:
>
Then we disagree on what 'multi-way' select might mean. I think it
means
branching, even if notionally, on one-of-N possible code paths.
>
OK.
>
I appreciate this is what Bart means by that phrase, but I don't agree
with it. I'm not sure if that is covered by "OK" or not!
>
You may prefer your own definition, but Bart's is resonable one.
The only argument I can make here is that I have not seen "multi-way
select" as a defined phrase with a particular established meaning.
>
Well, it started off as 2-way select, meaning constructs like this:
>
x = c ? a : b;
x := (c | a | b)
>
Where one of two branches is evaluated. I extended the latter to N-way
select:
>
x := (n | a, b, c, ... | z)
This looks quite error-prone. You have to count carefully that
the cases match the intended values. If an entry is
inserted, all the remaining ones shift to a higher value.
You've basically taken a case construct and auto-generated
the labels starting from 1.
If that was someone's Lisp macro, I would prefer they confine
it to their own program. :)
1> (defmacro nsel (expr . clauses)
^(caseql ,expr ,*[mapcar list 1 clauses]))
nsel
2> (nsel 1 (prinl "one") (prinl "two") (prinl "three"))
"one"
"one"
3> (nsel (+ 1 1) (prinl "one") (prinl "two") (prinl "three"))
"two"
"two"
4> (nsel (+ 1 3) (prinl "one") (prinl "two") (prinl "three"))
nil
5> (nsel (+ 1 2) (prinl "one") (prinl "two") (prinl "three"))
"three"
"three"
nil
6> (macroexpand-1 '(nsel x a b c d))
(caseql x (1 a)
(2 b) (3 c)
(4 d))
Yawn ...
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca