Discussion:
freeform swich case
(too old to reply)
fir
2024-08-25 10:53:21 UTC
Permalink
by freeform i thought something like
totally separate the function of switch and
teh function of case amd understand
it sepratelley

swich(a) menas something like select a (for later comparsions)
(though its not clear if it should select value or select
variable at this moment)

case(4) means coempare selected tith argument and
work like if


do

int a = rand()%10;

switch(a);
case(1) {}
case(2) {}
case(3) {}
case(4) {}
case(5) {}

is understood

but the question is the details, like mentioned
if select by value or by variable

switch(a);
case(1) {a++;}
case(2) {}
a--;
case(3) {a+=6;}
case(4) {}
case(5) {}

as it will work different then

such free form is somewhat low lewel than the normal
switch case imo..it also has no break but what it could
be seem if swich selects by value then probably break
is not needed as the other cases could be optimised
away (though maybe not fully..) if switch is by variable
then maybe less

overally this switch is a mess but it seem to me that this kind
of free form is better that the swich in c (though im not fully sure also)
fir
2024-08-25 11:21:24 UTC
Permalink
Post by fir
by freeform i thought something like
totally separate the function of switch and
teh function of case amd understand
it sepratelley
swich(a) menas something like select a (for later comparsions)
(though its not clear if it should select value or select
variable at this moment)
case(4) means coempare selected tith argument and
work like if
do
int a = rand()%10;
switch(a);
case(1) {}
case(2) {}
case(3) {}
case(4) {}
case(5) {}
is understood
but the question is the details, like mentioned
if select by value or by variable
switch(a);
case(1) {a++;}
case(2) {}
a--;
case(3) {a+=6;}
case(4) {}
case(5) {}
as it will work different then
such free form is somewhat low lewel than the normal
switch case imo..it also has no break but what it could
be seem if swich selects by value then probably break
is not needed as the other cases could be optimised
away (though maybe not fully..) if switch is by variable
then maybe less
overally this switch is a mess but it seem to me that this kind
of free form is better that the swich in c (though im not fully sure also)
yet one thing comes to mind as this switch /select (for smoe
reason select could be maybe a better word) could also work in
more ways than select variable and select value

it could also work like select value to watch in runtime, or select
value to watch at acces - and it could be eventually good for
debig purposes like

int x = 20;

select4ac(x); //select for acces controll

case(<0) ERROR("");
case(x>639) ERROR("");
//throws errors if x would be set below 0 or above 639



it would burden the cpu dependant on use but its kinda interesting
languege mechanism imo

Loading...