Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

An Ada exception is when a routine gets in trouble and says 'Beam me up, Scotty'.


devel / comp.lang.c / Re: thought on switch

SubjectAuthor
* thought on switchfir
`- Re: thought on switchfir

1
thought on switch

<6e9aecd2-cf7f-4db7-8c27-856f00af751cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21572&group=comp.lang.c#21572

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:a90e:0:b0:69f:9b8f:86b4 with SMTP id s14-20020a37a90e000000b0069f9b8f86b4mr4991853qke.513.1651406101032;
Sun, 01 May 2022 04:55:01 -0700 (PDT)
X-Received: by 2002:a05:622a:181a:b0:2f3:93ac:6859 with SMTP id
t26-20020a05622a181a00b002f393ac6859mr6567628qtc.74.1651406100875; Sun, 01
May 2022 04:55:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 1 May 2022 04:55:00 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.55; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.55
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6e9aecd2-cf7f-4db7-8c27-856f00af751cn@googlegroups.com>
Subject: thought on switch
From: profesor...@gmail.com (fir)
Injection-Date: Sun, 01 May 2022 11:55:01 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 74
 by: fir - Sun, 1 May 2022 11:55 UTC

watching a bit of code i used to compile when developing fury

void ProcessKeyDown int last_key_pressed :
int PAGE_UP{33}, int keyR{0x52}, int keyG{0x47}, int keyB{0x42}
last_key_pressed?=PAGE_UP: ToggleFullscreen .
last_key_pressed?=0x41: foo frame_size_x frame_size_y/2 3 4 .
last_key_pressed?=0x53: foo 2 3 4 5, foo 6 7 8 9 .
last_key_pressed?=0x43: MessageBoxA 0 "captionC\x00" "title\x00" 0 .
last_key_pressed?=keyR: AddBackgrounColor 0x10 .
last_key_pressed?=keyG: AddBackgrounColor 0x1000 .
last_key_pressed?=keyB: AddBackgrounColor 0x100000 .
return

i get to some thought that C switch is maybe not so much good idea
its becouse it lloks more than this key-values based container (called probably most commonly dictionary, im not sure) than a code construct... i mean maybe it it in fact better to see this as dictionary than code construct

more to say that code dictionaries could have a bigger use in C becouse you can share them semiglobally hovever im not sure if that wopuld bring doom (big mess) or something which is practically real improvement

by saring i mena it in facy can be defined

mydict (int key) = {
PAGE_UP: ToggleFullscreen ;
0x41: foo frame_size_x frame_size_y/2 3 4 ;
0x53: foo 2 3 4 5, foo 6 7 8 9 ;
0x43: MessageBoxA 0 "captionC\x00" "title\x00" 0;.
keyR: AddBackgrounColor 0x10 ;
keyG: AddBackgrounColor 0x1000 ;
keyB: AddBackgrounColor 0x100000 ;
} in fact on left side you can put not only a simple value that will be compared to key but if-like expression that uses key to check if execute contained value

some could say that it in fact makes a function
mydic(int key)
{ if(key>0) printf("a");
if(key<0) printf("b");
if(key==0) printf("c");
}

void foo()
{ for(int i=0; i<100; i++)
mydic(tab[i]);
} and maybe it is... so its like i lost the plot i thinked to generalize switch making it dictionary and returner to a concept of such if-block function but there may be something on this course of thought that is not prestented in current c syntax and semantics, im not sure it would need to be seen

(one thing is to allow such function to be inlined in (with acces to local variables)or simply contained in host function

void foo()
{ for(int i=0; i<100; i++)

mydic(int key = tab[i])
{ if(key>0) printf("a");
if(key<0) printf("b");
if(key==0) printf("c");
}

}

thet would need to be investigated (in a way i said i think, i mean trying so found something which is halfway a switch halfway a dictionary and halfway a function

Re: thought on switch

<215d2b28-46d1-423d-b6bd-ad3d88dceb4an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21573&group=comp.lang.c#21573

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:16c2:b0:69f:ca37:f6b5 with SMTP id a2-20020a05620a16c200b0069fca37f6b5mr3443310qkn.48.1651407541735;
Sun, 01 May 2022 05:19:01 -0700 (PDT)
X-Received: by 2002:a05:6214:23ce:b0:441:8296:a11e with SMTP id
hr14-20020a05621423ce00b004418296a11emr6150582qvb.16.1651407541575; Sun, 01
May 2022 05:19:01 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 1 May 2022 05:19:01 -0700 (PDT)
In-Reply-To: <6e9aecd2-cf7f-4db7-8c27-856f00af751cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.138; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.138
References: <6e9aecd2-cf7f-4db7-8c27-856f00af751cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <215d2b28-46d1-423d-b6bd-ad3d88dceb4an@googlegroups.com>
Subject: Re: thought on switch
From: profesor...@gmail.com (fir)
Injection-Date: Sun, 01 May 2022 12:19:01 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 89
 by: fir - Sun, 1 May 2022 12:19 UTC

niedziela, 1 maja 2022 o 13:55:08 UTC+2 fir napisał(a):
> watching a bit of code i used to compile when developing fury
>
> void ProcessKeyDown int last_key_pressed :
> int PAGE_UP{33}, int keyR{0x52}, int keyG{0x47}, int keyB{0x42}
> last_key_pressed?=PAGE_UP: ToggleFullscreen .
> last_key_pressed?=0x41: foo frame_size_x frame_size_y/2 3 4 .
> last_key_pressed?=0x53: foo 2 3 4 5, foo 6 7 8 9 .
> last_key_pressed?=0x43: MessageBoxA 0 "captionC\x00" "title\x00" 0 .
> last_key_pressed?=keyR: AddBackgrounColor 0x10 .
> last_key_pressed?=keyG: AddBackgrounColor 0x1000 .
> last_key_pressed?=keyB: AddBackgrounColor 0x100000 .
> return
>
> i get to some thought that C switch is maybe not so much good idea
> its becouse it lloks more than this key-values based container (called probably most commonly dictionary, im not sure) than a code construct... i mean maybe it it in fact better to see this as dictionary than code construct
>
> more to say that code dictionaries could have a bigger use in C becouse you can share them semiglobally hovever im not sure if that wopuld bring doom (big mess) or something which is practically real improvement
>
> by saring i mena it in facy can be defined
>
> mydict (int key) = {
> PAGE_UP: ToggleFullscreen ;
> 0x41: foo frame_size_x frame_size_y/2 3 4 ;
> 0x53: foo 2 3 4 5, foo 6 7 8 9 ;
> 0x43: MessageBoxA 0 "captionC\x00" "title\x00" 0;.
> keyR: AddBackgrounColor 0x10 ;
> keyG: AddBackgrounColor 0x1000 ;
> keyB: AddBackgrounColor 0x100000 ;
> }
> in fact on left side you can put not only a simple value that will be compared to key but if-like expression that uses key to check if execute contained value
>
> some could say that it in fact makes a function
> mydic(int key)
> {
> if(key>0) printf("a");
> if(key<0) printf("b");
> if(key==0) printf("c");
> }
>
> void foo()
> {
> for(int i=0; i<100; i++)
> mydic(tab[i]);
> }
> and maybe it is... so its like i lost the plot i thinked to generalize switch making it dictionary and returner to a concept of such if-block function but there may be something on this course of thought that is not prestented in current c syntax and semantics, im not sure it would need to be seen
>
> (one thing is to allow such function to be inlined in (with acces to local variables)or simply contained in host function
>
> void foo()
> {
> for(int i=0; i<100; i++)
>
> mydic(int key = tab[i])
> {
> if(key>0) printf("a");
> if(key<0) printf("b");
> if(key==0) printf("c");
> }
>
> }
>
> thet would need to be investigated (in a way i said i think, i mean trying so found something which is halfway a switch halfway a dictionary and halfway a function

possibly the form as for now could compile elements mentioned

(chars k) myswitch(chars k)
{ "aaa" : "ssccc";
"aacc" : "akjhs jshkjh"
"11" : " sddd"
if(len(k)<10) : " aaaaa"
"ruu" : { runsomething(); return " "; }
}

printf(myswitch(x))

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor