Deutsch English Français Italiano |
<672F3485.6090805@grunge.pl> View for Bookmarking (what is this?) Look up another Usenet article |
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!weretis.net!feeder8.news.weretis.net!news.neodome.net!rocksolid2!i2pn2.org!.POSTED!not-for-mail From: fir <fir@grunge.pl> Newsgroups: comp.lang.c Subject: Re: else ladders practice Date: Sat, 09 Nov 2024 11:08:05 +0100 Organization: i2pn2 (i2pn.org) Message-ID: <672F3485.6090805@grunge.pl> 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> <20241105173408.11@kylheku.com> <vgfepe$22j2u$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: i2pn2.org; logging-data="1653348"; mail-complaints-to="usenet@i2pn2.org"; posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0"; User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24 To: Bart <bc@freeuk.com> X-Spam-Checker-Version: SpamAssassin 4.0.0 In-Reply-To: <vgfepe$22j2u$1@dont-email.me> Bart wrote: > On 06/11/2024 07:26, Kaz Kylheku wrote: >> On 2024-11-05, Bart <bc@freeuk.com> wrote: > >>> 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. > > It's a version of Algol68's case construct: > > x := CASE n IN a, b, c OUT z ESAC > > which also has the same compact form I use. I only use the compact > version because n is usually small, and it is intended to be used within > an expression: print (n | "One", "Two", "Three" | "Other"). > > This an actual example (from my first scripting language; not written by > me): > > Crd[i].z := (BendAssen |P.x, P.y, P.z) > > An out-of-bounds index yields 'void' (via a '| void' part inserted by > the compiler). This is one of my examples from that era: > > xt := (messa | 1,1,1, 2,2,2, 3,3,3) > yt := (messa | 3,2,1, 3,2,1, 3,2,1) > still the more c compatimle version would look better imo xt = {1,1,1, 2,2,2, 3,3,3}[messa]; yt = {3,2,1, 3,2,1, 3,2,1}[messa]; esp if maybe there would be allowed to also use [] leftside and t = {1,3, 1,2, 1,1 2,3, 2,2, 2,1, 3,3, 3,2, 3,1} [messa] where t is struct {x,y} could be maybe faster > Algol68 didn't have 'switch', but I do, as well as a separate > case...esac statement that is more general. Those are better for > multi-line constructs. > > As for being error prone because values can get out of step, so is a > function call like this: > > f(a, b, c, d, e) > > But I also have keyword arguments. >