Deutsch   English   Français   Italiano  
<20241105173408.11@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

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>
 <vg2llt$38ons$1@dont-email.me>
 <2491a699388b5891a49ef960e1ad8bb689fdc2ed@i2pn2.org>
 <b681ee05856e165c26a5c29bf42a8d9d53843d6d@i2pn2.org>
 <vg2ttn$3a4lk$1@dont-email.me> <vg33gs$3b8n5$1@dont-email.me>
 <vg358c$3bk7t$1@dont-email.me> <vg37nr$3bo0c$1@dont-email.me>
 <vg3b98$3cc8q$1@dont-email.me> <vg5351$3pada$1@dont-email.me>
 <vg62vg$3uv02$1@dont-email.me> <vgd3ro$2pvl4$1@paganini.bofh.team>
 <vgd6jh$1hmjc$1@dont-email.me> <vgds97$2r682$1@paganini.bofh.team>
 <vgdvfj$1m6ho$1@dont-email.me> <vge84o$1o57r$2@dont-email.me>
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 <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/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca