Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <v9rb8f$22uj8$1@dont-email.me>
Deutsch   English   Français   Italiano  
<v9rb8f$22uj8$1@dont-email.me>

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

Path: ...!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: When Is A High/Low-Level Language Not A High/Low-Level Language?
Date: Sun, 18 Aug 2024 00:20:49 +0100
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <v9rb8f$22uj8$1@dont-email.me>
References: <v9mppi$1b5hk$1@dont-email.me> <v9ptfh$1s7lo$1@dont-email.me>
 <v9r76l$2289h$5@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 18 Aug 2024 01:20:48 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3b7af9ffbc5b2dc8e00c9bad01337f22";
	logging-data="2194024"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+IQPP3HnRCMOzZnIcA65eB"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Ntx9x7MvWkRlpiZ8V4hSRWk88XA=
In-Reply-To: <v9r76l$2289h$5@dont-email.me>
Content-Language: en-GB
Bytes: 3376

On 17/08/2024 23:11, Lawrence D'Oliveiro wrote:
> On Sat, 17 Aug 2024 11:19:30 +0100, Bart wrote:
> 
>> ... what does this have to do with C, or anything at all?
> 
> C is supposed to be the epitome of the low-level language that can do bit-
> fiddling and unsafe type conversions and the like. This is an example of
> an unsafe type conversion (offering a typesafe interface to the caller, of
> course) done dynamically, in a language which is generally considered to
> be “higher-level” than C.
> 
> In sum: types as first-class objects + low-level bit-fiddling = a
> combination unavailable in traditional “low-level” languages like C.
> 
>> Apart from being an apallingly bit of code.
> 
> How would you it less “apallingly”?
> 
> (This sentence no verb. Also speling.)

It's an adverb. Although there should have been two P's.

> 
>> However I can't see the switch-expression; there is a Dict constructor,
>> where all elements are evaluated, not just the one selected. That is not
>> how 'switch' works.
> 
> How does a switch-expression work, then? Can you give us an example?

Take this Python code that has a similar dict constructor:

   def prnt(x): print(x); return len(x)

   i=3
   a={1:prnt("One"), 2:prnt("Two"), 3:prnt("Three")}[i]

   print(a)

It selects the third element keyed with '3', but the output is:

   One
   Two
   Three
   5

So 'prnt' has been called 3 times instance of just once. (Also using a 
non-existent key gives an error.)

The equivalent using 'switch' in one of my languages (or anything 
expression-based that used any form of multi-way select) is this:

     fun prnt(x) = (println x; x.len)

     i := 3
     a :=
       switch i
       when 1 then prnt("One")
       when 2 then prnt("Two")
       when 3 then prnt("Three")
       else 0
       end

     println a

Output is:

     Three
     5

Only one branch has been evaluated. Plus there is a default value (it's 
required). Also, since the index values here are in sequence, I can use 
N-way select:

    a := (i | prnt("One"), prnt("Two"), prnt("Three") | 0)

Same result. You can't use a list here plus normal indexing, as again 
all elements would be evaluated.