Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: else ladders practice Date: Wed, 6 Nov 2024 07:26:25 -0000 (UTC) Organization: A noiseless patient Spider Lines: 67 Message-ID: <20241105173408.11@kylheku.com> References: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org> <2491a699388b5891a49ef960e1ad8bb689fdc2ed@i2pn2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 06 Nov 2024 08:26:25 +0100 (CET) Injection-Info: dont-email.me; posting-host="29ed08caef40dd2f4f3bddf64a0933dc"; logging-data="2126990"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fMC6HWqChqxYx38VibTINpv12OoZMGOc=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:7v0LT3GHBkhjGSgbS1DzsaJMSkg= Bytes: 3548 On 2024-11-05, Bart wrote: > On 05/11/2024 20:33, David Brown wrote: >> On 05/11/2024 20:39, Waldek Hebisch wrote: >>> David Brown wrote: >>>> On 05/11/2024 13:42, Waldek Hebisch wrote: >>>>> Bart 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/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca