Topic: A more advanced switch
Author: costelnistor12@gmail.com
Date: Tue, 1 Aug 2017 14:24:04 -0700 (PDT)
Raw View
------=_Part_5435_1704948266.1501622644132
Content-Type: multipart/alternative;
boundary="----=_Part_5436_466158694.1501622644133"
------=_Part_5436_466158694.1501622644133
Content-Type: text/plain; charset="UTF-8"
Hello, I'm sorry if you talked about this here before, but I didn't watch
this group and I couldn't find this thing when searching.
I'm coming from another language named Pawn, it looks like C ~80%, but it
has more advantages than C. Here's the official
page: https://www.compuphase.com/pawn/pawn.htm .
A problem in C++: "switch" is exactly like in C, I think it deserves an
upgrade, as it can be used a lot, providing more speed and easier syntax
than lots of "if" ... "else if" ... "else" lines. I know that simply
updating it would break compatibility, so it may require another name
instead of switch, or you can find any other backwards compatible
alternative. I bet you can do this perfectly.
For cases 0, 1, 2, 3, 4 and 5, 6 and "default" in C++ we have to do it like
switch( variable )
{
case 0: case 1: case 2: case 3: case 4:
{
// ...
break;
}
case 5: case 6:
{
// ...
break;
}
default:
{
// ...
}
}
We have to use "case" for every, well, case when specifying a sequence,
because it uses fallthrough. We have to use "break" to avoid that. I find
this bad. Because of the necessity of using "break" we can't just "break"
out of a loop if the switch is inside a loop. Also, if there are
consecutive cases we have to specify each one of them. Additionally, we
could also forget breaking. This "switch" isn't safe and is pretty old.
In Pawn we can do it a lot better:
switch( variable )
{
case 0 .. 4:
{
// ...
}
case 5, 6:
{
// ...
}
default:
{
// ...
}
}
1. There's no need for break, there's no fallthrough. Advantage: we can
easily "continue" and "break" loops from inside the "switch".
2. We can use ".." if using several cases that are consecutive in the same
block of code, to specify an interval.
I know that it's hard to have features accepted in such a popular standard,
but upgrading switch is something that should really be considered !
C++17's [[fallthrough]] attribute is just as complicated as the "switch".
It needs to be added everywhere or else we would get warnings (AFAIK).
C++ needs a lot more syntactic sugar. Small and nice things are making the
language more likeable. I think that you should watch other languages too
for interesting small features.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f8c908e2-d06f-4cd1-bda0-fe2b97fd21f1%40isocpp.org.
------=_Part_5436_466158694.1501622644133
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello, I'm sorry if you talked about this here before,=
but I didn't watch this group and I couldn't find this thing when =
searching.<div><br></div><div>I'm coming from another language named Pa=
wn, it looks like C ~80%, but it has more advantages than C. Here's the=
official page:=C2=A0https://www.compuphase.com/pawn/pawn.htm .</div><div><=
br></div><div>A problem in C++: "switch" is exactly like in C, I =
think it deserves an upgrade, as it can be used a lot, providing more speed=
and easier syntax than lots of "if" ... "else if" ... =
"else" lines. I know that simply updating it would break compatib=
ility, so it may require another name instead of switch, or you can find an=
y other backwards compatible alternative. I bet you can do this perfectly.<=
div><br></div><div>For cases 0, 1, 2, 3, 4 and 5, 6 and "default"=
in C++ we have to do it like</div><div class=3D"prettyprint" style=3D"back=
ground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-=
style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pre=
ttyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">switch</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> variable </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">cas=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">2</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">case</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">case</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">4</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// ...</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">break</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">case</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify=
">6</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">// ...</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">break</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">default</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">// ...</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span></div></code></div><div><br></div><div>We h=
ave to use "case" for every, well, case when specifying a sequenc=
e, because it uses fallthrough. We have to use "break" to avoid t=
hat. I find this bad. Because of the necessity of using "break" w=
e can't just "break" out of a loop if the switch is inside a =
loop. Also, if there are consecutive cases we have to specify each one of t=
hem. Additionally, we could also forget breaking. This "switch" i=
sn't safe and is pretty old.</div><div><br></div><div>In Pawn we can do=
it a lot better:</div><div><div class=3D"prettyprint" style=3D"background-=
color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: =
solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprin=
t"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">switch</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> variable </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">0</span><font color=3D"#6666=
00"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">..</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span></font><span style=
=3D"color: #066;" class=3D"styled-by-prettify">4</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">// ...</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">5</span><font color=3D"#666600"=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span></font><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">6</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">// ...</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">default</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// ...=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0=
=C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></c=
ode></div><span class=3D"styled-by-prettify" style=3D"font-family: monospac=
e; background-color: rgb(250, 250, 250); color: rgb(102, 102, 0);"><br></sp=
an>1. There's no need for break, there's no fallthrough. Advantage:=
we can easily "continue" and "break" loops from inside=
the "switch".</div><div>2. We can use ".." if using se=
veral cases that are consecutive in the same block of code, to specify an i=
nterval.</div><div><br></div><div>I know that it's hard to have feature=
s accepted in such a popular standard, but upgrading switch is something th=
at should really be considered ! C++17's [[fallthrough]] attribute is j=
ust as complicated as the "switch". It needs to be added everywhe=
re or else we would get warnings (AFAIK).</div><div><br></div><div>C++ need=
s a lot more syntactic sugar. Small and nice things are making the language=
more likeable. I think that you should watch other languages too for inter=
esting small features.</div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f8c908e2-d06f-4cd1-bda0-fe2b97fd21f1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f8c908e2-d06f-4cd1-bda0-fe2b97fd21f1=
%40isocpp.org</a>.<br />
------=_Part_5436_466158694.1501622644133--
------=_Part_5435_1704948266.1501622644132--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 01 Aug 2017 14:34:23 -0700
Raw View
On ter=C3=A7a-feira, 1 de agosto de 2017 14:24:04 PDT costelnistor12@gmail.=
com=20
wrote:
> We have to use "case" for every, well, case when specifying a sequence,
> because it uses fallthrough. We have to use "break" to avoid that. I find
> this bad. Because of the necessity of using "break" we can't just "break"
> out of a loop if the switch is inside a loop. Also, if there are
> consecutive cases we have to specify each one of them. Additionally, we
> could also forget breaking. This "switch" isn't safe and is pretty old.
>=20
> In Pawn we can do it a lot better:
> switch( variable )
> {
> case 0 .. 4:
With GNU extensions to C and C++:
case 0 ... 4:
> 1. There's no need for break, there's no fallthrough. Advantage: we can
> easily "continue" and "break" loops from inside the "switch".
That can't change now. This HAS been discussed in this list and in std-
discussions and, just like the non-local breaks, it's very hard to adapt th=
e=20
language grammar to.
We need a different keyword or some modification keyword to the switch, sin=
ce=20
there is unmarked code that expects to fall through. We cannot silently bre=
ak=20
them.
> I know that it's hard to have features accepted in such a popular standar=
d,
> but upgrading switch is something that should really be considered !
> C++17's [[fallthrough]] attribute is just as complicated as the "switch".
> It needs to be added everywhere or else we would get warnings (AFAIK).
We've done that in Qt. Not very difficult once the compiler starts warning.
The difficult part is to guess whether a fallthrough was intended or a brea=
k was=20
missing.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/34130636.8iyeqGTS6R%40tjmaciei-mobl1.
.
Author: Vishal Oza <vickoza@gmail.com>
Date: Tue, 1 Aug 2017 14:53:28 -0700 (PDT)
Raw View
------=_Part_5557_1167485148.1501624408083
Content-Type: text/plain; charset="UTF-8"
I like the idea of adding new of adding to the switch statement but I think lets take it futher
switch (v)
{
case v= [1,5]: //incusive 1 to 5 1 <= v <= 5
Dosomething();
break;
case v = (5, 10): //exclusive range 5 < v < 10
doSomethingelse1();
break;
case v = (10, 50 ]: // 10 < v <= 50
doSomethingElse2();
break;
case v = (50,...) // 50 < v
doSomethingElse3();
break;
case v = 50:
doSomethingElse4();
break;
}
Valid for only if v is numeric also add multi variable values and strings
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9d888362-46f2-4317-b4ea-4376159d8ef1%40isocpp.org.
------=_Part_5557_1167485148.1501624408083--
.
Author: wei zhang <lala.willzhang@gmail.com>
Date: Tue, 1 Aug 2017 23:19:39 -0700 (PDT)
Raw View
------=_Part_5202_965121556.1501654779451
Content-Type: multipart/alternative;
boundary="----=_Part_5203_1138877533.1501654779451"
------=_Part_5203_1138877533.1501654779451
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
We can only add silently with case 5, 6:
=E5=9C=A8 2017=E5=B9=B48=E6=9C=882=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89 UTC+=
8=E4=B8=8A=E5=8D=885:34:29=EF=BC=8CThiago Macieira=E5=86=99=E9=81=93=EF=BC=
=9A
>
> On ter=C3=A7a-feira, 1 de agosto de 2017 14:24:04 PDT costeln...@gmail.co=
m=20
> <javascript:>=20
> wrote:=20
> > We have to use "case" for every, well, case when specifying a sequence,=
=20
> > because it uses fallthrough. We have to use "break" to avoid that. I=20
> find=20
> > this bad. Because of the necessity of using "break" we can't just=20
> "break"=20
> > out of a loop if the switch is inside a loop. Also, if there are=20
> > consecutive cases we have to specify each one of them. Additionally, we=
=20
> > could also forget breaking. This "switch" isn't safe and is pretty old.=
=20
> >=20
> > In Pawn we can do it a lot better:=20
> > switch( variable )=20
> > {=20
> > case 0 .. 4:=20
>
> With GNU extensions to C and C++:=20
>
> case 0 ... 4:=20
>
> > 1. There's no need for break, there's no fallthrough. Advantage: we can=
=20
> > easily "continue" and "break" loops from inside the "switch".=20
>
> That can't change now. This HAS been discussed in this list and in std-=
=20
> discussions and, just like the non-local breaks, it's very hard to adapt=
=20
> the=20
> language grammar to.=20
>
> We need a different keyword or some modification keyword to the switch,=
=20
> since=20
> there is unmarked code that expects to fall through. We cannot silently=
=20
> break=20
> them.=20
>
> > I know that it's hard to have features accepted in such a popular=20
> standard,=20
> > but upgrading switch is something that should really be considered !=20
> > C++17's [[fallthrough]] attribute is just as complicated as the=20
> "switch".=20
> > It needs to be added everywhere or else we would get warnings (AFAIK).=
=20
>
> We've done that in Qt. Not very difficult once the compiler starts=20
> warning.=20
>
> The difficult part is to guess whether a fallthrough was intended or a=20
> break was=20
> missing.=20
>
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
> Software Architect - Intel Open Source Technology Center=20
>
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/68a9dd6e-7e33-4e3a-96da-24fe435eda5a%40isocpp.or=
g.
------=_Part_5203_1138877533.1501654779451
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">We can only add silently with case 5, 6:<div><br></div><di=
v><br><div><br><br>=E5=9C=A8 2017=E5=B9=B48=E6=9C=882=E6=97=A5=E6=98=9F=E6=
=9C=9F=E4=B8=89 UTC+8=E4=B8=8A=E5=8D=885:34:29=EF=BC=8CThiago Macieira=E5=
=86=99=E9=81=93=EF=BC=9A<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On ter=
=C3=A7a-feira, 1 de agosto de 2017 14:24:04 PDT <a href=3D"javascript:" tar=
get=3D"_blank" gdf-obfuscated-mailto=3D"Z8Ui7RrhBAAJ" rel=3D"nofollow" onmo=
usedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.=
href=3D'javascript:';return true;">costeln...@gmail.com</a>=20
<br>wrote:
<br>> We have to use "case" for every, well, case when specify=
ing a sequence,
<br>> because it uses fallthrough. We have to use "break" to a=
void that. I find
<br>> this bad. Because of the necessity of using "break" we c=
an't just "break"
<br>> out of a loop if the switch is inside a loop. Also, if there are
<br>> consecutive cases we have to specify each one of them. Additionall=
y, we
<br>> could also forget breaking. This "switch" isn't safe=
and is pretty old.
<br>>=20
<br>> In Pawn we can do it a lot better:
<br>> switch( variable )
<br>> {
<br>> =C2=A0 =C2=A0 case 0 .. 4:
<br>
<br>With GNU extensions to C and C++:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0case 0 ... 4:
<br>
<br>> 1. There's no need for break, there's no fallthrough. Adva=
ntage: we can
<br>> easily "continue" and "break" loops from insid=
e the "switch".
<br>
<br>That can't change now. This HAS been discussed in this list and in =
std-
<br>discussions and, just like the non-local breaks, it's very hard to =
adapt the=20
<br>language grammar to.
<br>
<br>We need a different keyword or some modification keyword to the switch,=
since=20
<br>there is unmarked code that expects to fall through. We cannot silently=
break=20
<br>them.
<br>
<br>> I know that it's hard to have features accepted in such a popu=
lar standard,
<br>> but upgrading switch is something that should really be considered=
!
<br>> C++17's [[fallthrough]] attribute is just as complicated as th=
e "switch".
<br>> It needs to be added everywhere or else we would get warnings (AFA=
IK).
<br>
<br>We've done that in Qt. Not very difficult once the compiler starts =
warning.
<br>
<br>The difficult part is to guess whether a fallthrough was intended or a =
break was=20
<br>missing.
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.hr=
ef=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/68a9dd6e-7e33-4e3a-96da-24fe435eda5a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/68a9dd6e-7e33-4e3a-96da-24fe435eda5a=
%40isocpp.org</a>.<br />
------=_Part_5203_1138877533.1501654779451--
------=_Part_5202_965121556.1501654779451--
.
Author: Bo Persson <bop@gmb.dk>
Date: Wed, 2 Aug 2017 11:20:39 +0200
Raw View
On 2017-08-01 23:53, Vishal Oza wrote:
> I like the idea of adding new of adding to the switch statement but I think lets take it futher
> switch (v)
> {
> case v= [1,5]: //incusive 1 to 5 1 <= v <= 5
> Dosomething();
> break;
> case v = (5, 10): //exclusive range 5 < v < 10
> doSomethingelse1();
> break;
> case v = (10, 50 ]: // 10 < v <= 50
> doSomethingElse2();
> break;
> case v = (50,...) // 50 < v
> doSomethingElse3();
> break;
> case v = 50:
> doSomethingElse4();
> break;
> }
> Valid for only if v is numeric also add multi variable values and strings
>
If you have large ranges, the compiler might translate that similar to
an if-statement anyway. Especially the (50,...) cannot easily be used in
a jump table.
Bo Persson
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ols5h1%24450%241%40blaine.gmane.org.
.
Author: Bo Persson <bop@gmb.dk>
Date: Wed, 2 Aug 2017 11:25:01 +0200
Raw View
On 2017-08-01 23:24, costelnistor12@gmail.com wrote:
>
> I know that it's hard to have features accepted in such a popular
> standard, but upgrading switch is something that should really be
> considered ! C++17's [[fallthrough]] attribute is just as complicated as
> the "switch". It needs to be added everywhere or else we would get
> warnings (AFAIK).
>
In my experience it was just a handful of places in a (not that large)
code base. And most of those places already had a comment that the
fall-through was intentional.
Bo Persson
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ols5p7%24lha%241%40blaine.gmane.org.
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Wed, 2 Aug 2017 10:58:38 -0400
Raw View
On 2017-08-01 17:24, costelnistor12@gmail.com wrote:
> 1. There's no need for break, there's no fallthrough. Advantage: we can
> easily "continue" and "break" loops from inside the "switch".
Disadvantage: you can't do this:
case FOO:
...some code...
[[fallthrough]];
case BAR:
...more code...
break;
And yes, I've actually written code like that before.
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/14c4337e-0b20-6c84-3f03-1db9583faa0b%40gmail.com.
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 02 Aug 2017 08:00:09 -0700
Raw View
On Wednesday, 2 August 2017 02:25:01 PDT Bo Persson wrote:
> In my experience it was just a handful of places in a (not that large)
> code base. And most of those places already had a comment that the
> fall-through was intentional.
There were a couple that didn't and those are the ones that took time to
investigate.
I think it was about 10 inside the Qt entire codebase (which OpenHub clocks at
7.9 million LOC).
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2907027.xNHN6QKsd3%40tjmaciei-mobl1.
.
Author: Ross Smith <ross.smith@otoy.com>
Date: Thu, 3 Aug 2017 09:18:33 +1200
Raw View
On 2017-08-02 21:20, Bo Persson wrote:
> On 2017-08-01 23:53, Vishal Oza wrote:
>> I like the idea of adding new of adding to the switch statement but I
>> think lets take it futher
>> switch (v)
>> {
>> case v= [1,5]: //incusive 1 to 5 1 <= v <= 5
>> Dosomething();
>> break;
>> case v = (5, 10): //exclusive range 5 < v < 10
>> doSomethingelse1();
>> break;
>> case v = (10, 50 ]: // 10 < v <= 50
>> doSomethingElse2();
>> break;
>> case v = (50,...) // 50 < v
>> doSomethingElse3();
>> break;
>> case v = 50:
>> doSomethingElse4();
>> break;
>> }
>> Valid for only if v is numeric also add multi variable values and strings
>>
>
> If you have large ranges, the compiler might translate that similar to
> an if-statement anyway. Especially the (50,...) cannot easily be used in
> a jump table.
There's only so much elaboration that could be added to the switch
statement before it stops offering any meaningful advantage in
convenience or readability over just manually writing the equivalent
sequence of if-elses.
Ross Smith
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/722a37ea-6d3c-952a-f75e-376259a427cb%40otoy.com.
.
Author: Cleiton Santoia <cleitonsantoia@gmail.com>
Date: Wed, 2 Aug 2017 21:29:01 -0700 (PDT)
Raw View
------=_Part_6738_195466846.1501734541603
Content-Type: multipart/alternative;
boundary="----=_Part_6739_928355533.1501734541603"
------=_Part_6739_928355533.1501734541603
Content-Type: text/plain; charset="UTF-8"
>
> There's only so much elaboration that could be added to the switch
> statement before it stops offering any meaningful advantage in
> convenience or readability over just manually writing the equivalent
> sequence of if-elses.
>
My "pet switch" would allow many conditions at once,and could be used in
"not jump table" cases, like any object:
std::string x = "AF-56";
int k = 90;
enum YesNo{ NO,YES } answer;
switch ( answer, k, x.substr(0,2) ) {
case NO, default : // enters here if answer is NO and not check any of the
others
break;
case YES, 10r.80r, default : // enters here if answer is yes and if k is in
range 10-90, forget the third parameter
// using UDL 'r' suffix and dot operator we
may create a range that can compares thru operator == to a scalar
break;
case YES, 81, "XY" : // no surprises here
break;
case YES, 82r.Inf, "XZ" : // the range now is from 82 to infinity
break;
case YES, 90, "AA"r."AX"r : // ranges can be of std::strings too ( or const
char* ), why not ?
// This is actually the case that will be reached by (YES, 90, "AF")
break;
case default:
}
I know, comma may create problems, one may replace ',' with ';'
This was my 2 cents
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a6db0e72-dc61-4914-9508-31e2bc2c7462%40isocpp.org.
------=_Part_6739_928355533.1501734541603
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">There's o=
nly so much elaboration that could be added to the switch=20
<br>statement before it stops offering any meaningful advantage in=20
<br>convenience or readability over just manually writing the equivalent=20
<br>sequence of if-elses.<br></blockquote><div><br></div><div>My "pet =
switch" =C2=A0would allow many conditions at once,and could be used in=
"not jump table" cases, like any object:</div><div><br></div><di=
v><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250);=
border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; =
word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpretty=
print"><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">"AF-56"</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> k </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">90</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">enum</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">YesNo</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> NO</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">YES =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> answer</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">switch</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> answer</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> k</span><font color=3D"#666600"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span></font><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">substr</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">2</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #008;" class=3D"styled-by-prettify">case</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> NO</span><font=
color=3D"#666600"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">,</span></font><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">default</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// enters here if answer is NO and no=
t check any of the others</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">break</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">case</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Y=
ES</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">10r</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">80r</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">default</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #800;" class=3D"styled-by-prettify">// enters here if answ=
er is yes and if k is in range 10-90, forget the third parameter</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">// using UDL 'r' suffix and dot operator we may create a range t=
hat can compares thru operator =3D=3D to a scalar</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">break</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> YES</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">81<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><font color=
=3D"#008800"><span style=3D"color: #080;" class=3D"styled-by-prettify">&quo=
t;XY"</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span><spa=
n style=3D"color: #800;" class=3D"styled-by-prettify">// no surprises here =
=C2=A0 </span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span></font><span style=3D"color: #000;" class=3D"styled-by-prettify">=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">break</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> YES</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">82r</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Inf</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><font color=3D"#008800"><span style=3D"color: #080;" class=3D"styled=
-by-prettify">"XZ"</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
=C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
the range now is from 82 to infinity</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span></font><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">=C2=A0 =C2=A0 </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">break</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">case</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> YES</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">90</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;"=
class=3D"styled-by-prettify">"AA"</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">r</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">.</span><span style=3D"color: #080;" class=3D"styl=
ed-by-prettify">"AX"</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">r </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// ran=
ges can be of std::strings too ( or const char* ),</span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify"> why not ?</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// This is actually the=
case that will be reached by (YES, 90, "AF")</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">break</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">case</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">default</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> <br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span></div></code></div><br></div><div><br></div><div>I know, comma =
may create problems, one may replace ',' with ';'</div><div=
><br></div><div>This was my 2 cents</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a6db0e72-dc61-4914-9508-31e2bc2c7462%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a6db0e72-dc61-4914-9508-31e2bc2c7462=
%40isocpp.org</a>.<br />
------=_Part_6739_928355533.1501734541603--
------=_Part_6738_195466846.1501734541603--
.
Author: olafvdspek@gmail.com
Date: Wed, 9 Aug 2017 04:55:37 -0700 (PDT)
Raw View
------=_Part_3735_473748656.1502279738054
Content-Type: multipart/alternative;
boundary="----=_Part_3736_1460796780.1502279738054"
------=_Part_3736_1460796780.1502279738054
Content-Type: text/plain; charset="UTF-8"
I'd like to see a generalization of switch, allowing it to be used with for
example std::string (view).
std::string s;
switch (s)
{
case "A":
case "B":
default:
}
No syntax updates necessary.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5a36b655-b2a9-4be2-8599-465810cfd1b3%40isocpp.org.
------=_Part_3736_1460796780.1502279738054
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I'd like to see a generalization of switch, allowing i=
t to be used with for example std::string (view).<div><br></div><div>std::s=
tring s;</div><div><br></div><div>switch (s)</div><div>{</div><div>case &qu=
ot;A":=C2=A0</div><div>case "B":=C2=A0</div><div>default:</d=
iv><div>}</div><div><br></div><div>No syntax updates necessary.</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5a36b655-b2a9-4be2-8599-465810cfd1b3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5a36b655-b2a9-4be2-8599-465810cfd1b3=
%40isocpp.org</a>.<br />
------=_Part_3736_1460796780.1502279738054--
------=_Part_3735_473748656.1502279738054--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 9 Aug 2017 15:09:35 +0300
Raw View
On 9 August 2017 at 14:55, <olafvdspek@gmail.com> wrote:
> I'd like to see a generalization of switch, allowing it to be used with for
> example std::string (view).
>
> std::string s;
>
> switch (s)
> {
> case "A":
> case "B":
> default:
> }
>
> No syntax updates necessary.
That's not a switch, that's an if-else chain masquerading as a switch.
I would strongly
suggest adding a pattern-matching mechanism and leaving switch alone; switch has
semantics that don't fit into general matching, and other expectations
that a general
matching mechanism doesn't have, including recommendations against using switch
because switch does fall-through and a general matching mechanism
probably shouldn't.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYqZVo775jwQP%2BAGiqf3JRq8yNxB1Ru_b74YPa-qJfooA%40mail.gmail.com.
.
Author: gmisocpp@gmail.com
Date: Wed, 9 Aug 2017 06:08:05 -0700 (PDT)
Raw View
------=_Part_5174_1310644540.1502284085716
Content-Type: multipart/alternative;
boundary="----=_Part_5175_654013518.1502284085717"
------=_Part_5175_654013518.1502284085717
Content-Type: text/plain; charset="UTF-8"
I would very much like to see some changes to switch.
I'd like something like:
switch break (x) // cases break by default;
{
case 1: whatever();
case 2: whatever();
}
I'd also like, for at least this variation of switch, for a case to be a
scope by default, such that is ok:
So that variables can be declared without requiring more braces.
switch break (x) // cases break by default;
{
case 1: int z = 1; whatever(z); // not an error
case 2: whatever();
}
I think this would make most switch statements a lot less verbose.
It seems a lot of the flexibility of the classic switch just isn't required.
So this switch could be used when it's not and the existing switch can be
used when it is.
switch break seems easy to teach to me. So why not?
On Wednesday, August 2, 2017 at 9:24:04 AM UTC+12, costeln...@gmail.com
wrote:
> Hello, I'm sorry if you talked about this here before, but I didn't watch
> this group and I couldn't find this thing when searching.
>
> I'm coming from another language named Pawn, it looks like C ~80%, but it
> has more advantages than C. Here's the official page:
> https://www.compuphase.com/pawn/pawn.htm .
>
> A problem in C++: "switch" is exactly like in C, I think it deserves an
> upgrade, as it can be used a lot, providing more speed and easier syntax
> than lots of "if" ... "else if" ... "else" lines. I know that simply
> updating it would break compatibility, so it may require another name
> instead of switch, or you can find any other backwards compatible
> alternative. I bet you can do this perfectly.
>
> For cases 0, 1, 2, 3, 4 and 5, 6 and "default" in C++ we have to do it like
> switch( variable )
> {
> case 0: case 1: case 2: case 3: case 4:
> {
> // ...
> break;
> }
>
> case 5: case 6:
> {
> // ...
> break;
> }
>
> default:
> {
> // ...
> }
> }
>
> We have to use "case" for every, well, case when specifying a sequence,
> because it uses fallthrough. We have to use "break" to avoid that. I find
> this bad. Because of the necessity of using "break" we can't just "break"
> out of a loop if the switch is inside a loop. Also, if there are
> consecutive cases we have to specify each one of them. Additionally, we
> could also forget breaking. This "switch" isn't safe and is pretty old.
>
> In Pawn we can do it a lot better:
> switch( variable )
> {
> case 0 .. 4:
> {
> // ...
> }
>
> case 5, 6:
> {
> // ...
> }
>
> default:
> {
> // ...
> }
> }
>
> 1. There's no need for break, there's no fallthrough. Advantage: we can
> easily "continue" and "break" loops from inside the "switch".
> 2. We can use ".." if using several cases that are consecutive in the same
> block of code, to specify an interval.
>
> I know that it's hard to have features accepted in such a popular
> standard, but upgrading switch is something that should really be
> considered ! C++17's [[fallthrough]] attribute is just as complicated as
> the "switch". It needs to be added everywhere or else we would get warnings
> (AFAIK).
>
> C++ needs a lot more syntactic sugar. Small and nice things are making the
> language more likeable. I think that you should watch other languages too
> for interesting small features.
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/574320af-c1ae-4676-883c-ae4e91fcd874%40isocpp.org.
------=_Part_5175_654013518.1502284085717
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><br></div><div>I would very much like to see some cha=
nges to switch.</div><div><br></div><div>I'd like something like:</div>=
<div><br></div><div>switch break (x) // cases break by default;</div><div>{=
</div><div>=C2=A0=C2=A0=C2=A0 case 1: whatever();</div><div>=C2=A0=C2=A0=C2=
=A0=C2=A0case 2: whatever();<br>}</div><div><br></div><div>I'd also lik=
e, for at least this variation of switch,=C2=A0for=C2=A0a case=C2=A0to be a=
scope by default, such that is ok:</div><div>So that variables can be decl=
ared without requiring more braces.</div><div><br></div><div><div>switch br=
eak (x) // cases break by default;</div><div>{</div><div>=C2=A0=C2=A0=C2=A0=
case 1: int z =3D 1; whatever(z); // not an error</div><div>=C2=A0=C2=A0=
=C2=A0=C2=A0case 2: whatever();<br>}</div><div><br></div><div>I think this =
would make most switch statements a lot less verbose.</div><div>It seems a =
lot of the flexibility of the classic switch just isn't required.</div>=
<div>So this switch could be used when it's not and the existing switch=
can be used when it is.</div><div><br></div><div>switch break seems easy t=
o teach to me. So why not?<br><br><br>On Wednesday, August 2, 2017 at 9:24:=
04 AM UTC+12, costeln...@gmail.com wrote:</div></div><blockquote class=3D"g=
mail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-l=
eft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: s=
olid;"><div dir=3D"ltr">Hello, I'm sorry if you talked about this here =
before, but I didn't watch this group and I couldn't find this thin=
g when searching.<div><br></div><div>I'm coming from another language n=
amed Pawn, it looks like C ~80%, but it has more advantages than C. Here=
9;s the official page:=C2=A0<a onmousedown=3D"this.href=3D'https://www.=
google.com/url?q\x3dhttps%3A%2F%2Fwww.compuphase.com%2Fpawn%2Fpawn.htm\x26s=
a\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF6HwzHRS3ePvT8Rb_fa7FAjq_ktA';retur=
n true;" onclick=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%=
3A%2F%2Fwww.compuphase.com%2Fpawn%2Fpawn.htm\x26sa\x3dD\x26sntz\x3d1\x26usg=
\x3dAFQjCNF6HwzHRS3ePvT8Rb_fa7FAjq_ktA';return true;" href=3D"https://w=
ww.compuphase.com/pawn/pawn.htm" target=3D"_blank" rel=3D"nofollow">https:/=
/www.compuphase.<wbr>com/pawn/pawn.htm</a> .</div><div><br></div><div>A pro=
blem in C++: "switch" is exactly like in C, I think it deserves a=
n upgrade, as it can be used a lot, providing more speed and easier syntax =
than lots of "if" ... "else if" ... "else" li=
nes. I know that simply updating it would break compatibility, so it may re=
quire another name instead of switch, or you can find any other backwards c=
ompatible alternative. I bet you can do this perfectly.<div><br></div><div>=
For cases 0, 1, 2, 3, 4 and 5, 6 and "default" in C++ we have to =
do it like</div><div style=3D"border: 1px solid rgb(187, 187, 187); border-=
image: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, 250=
);"><code><div><span style=3D"color: rgb(0, 0, 136);">switch</span><span st=
yle=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0)=
;"> variable </span><span style=3D"color: rgb(102, 102, 0);">)</span><span =
style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 10=
2, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: rgb(0, 0, 136);">case</span><span style=3D"color: =
rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">0</span><sp=
an style=3D"color: rgb(102, 102, 0);">:</span><span style=3D"color: rgb(0, =
0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">case</span><span sty=
le=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);=
">1</span><span style=3D"color: rgb(102, 102, 0);">:</span><span style=3D"c=
olor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">case</s=
pan><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(=
0, 102, 102);">2</span><span style=3D"color: rgb(102, 102, 0);">:</span><sp=
an style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 1=
36);">case</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(0, 102, 102);">3</span><span style=3D"color: rgb(102, 102, 0=
);">:</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(0, 0, 136);">case</span><span style=3D"color: rgb(0, 0, 0);"> </spa=
n><span style=3D"color: rgb(0, 102, 102);">4</span><span style=3D"color: rg=
b(102, 102, 0);">:</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=
=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span styl=
e=3D"color: rgb(136, 0, 0);">// ...</span><span style=3D"color: rgb(0, 0, 0=
);"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: rgb(0, 0, =
136);">break</span><span style=3D"color: rgb(102, 102, 0);">;</span><span s=
tyle=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0, 0, 0);"><br><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: rgb(0, 0, 136);">case</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, =
102);">5</span><span style=3D"color: rgb(102, 102, 0);">:</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">ca=
se</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color:=
rgb(0, 102, 102);">6</span><span style=3D"color: rgb(102, 102, 0);">:</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);">=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: rgb(136, 0, 0)=
;">// ...</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: rgb(0, 0, 136);">break</span><span =
style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, =
0);"><br>=C2=A0 =C2=A0 </span><span style=3D"color: rgb(102, 102, 0);">}</s=
pan><span style=3D"color: rgb(0, 0, 0);"><br><br>=C2=A0 =C2=A0 </span><span=
style=3D"color: rgb(0, 0, 136);">default</span><span style=3D"color: rgb(1=
02, 102, 0);">:</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"=
color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D=
"color: rgb(136, 0, 0);">// ...</span><span style=3D"color: rgb(0, 0, 0);">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color: rgb(102, 102, 0);">}</span><=
span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(10=
2, 102, 0);">}</span></div></code></div><div><br></div><div>We have to use =
"case" for every, well, case when specifying a sequence, because =
it uses fallthrough. We have to use "break" to avoid that. I find=
this bad. Because of the necessity of using "break" we can't=
just "break" out of a loop if the switch is inside a loop. Also,=
if there are consecutive cases we have to specify each one of them. Additi=
onally, we could also forget breaking. This "switch" isn't sa=
fe and is pretty old.</div><div><br></div><div>In Pawn we can do it a lot b=
etter:</div><div><div style=3D"border: 1px solid rgb(187, 187, 187); border=
-image: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, 25=
0);"><code><div><span style=3D"color: rgb(0, 0, 136);">switch</span><span s=
tyle=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0=
);"> variable </span><span style=3D"color: rgb(102, 102, 0);">)</span><span=
style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 1=
02, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color: rgb(0, 0, 136);">case</span><span style=3D"color:=
rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">0</span><f=
ont color=3D"#666600"><span style=3D"color: rgb(0, 0, 0);"> </span><span st=
yle=3D"color: rgb(102, 102, 0);">..</span><span style=3D"color: rgb(0, 0, 0=
);"> </span></font><span style=3D"color: rgb(0, 102, 102);">4</span><span s=
tyle=3D"color: rgb(102, 102, 0);">:</span><span style=3D"color: rgb(0, 0, 0=
);"><br>=C2=A0 =C2=A0 </span><span style=3D"color: rgb(102, 102, 0);">{</sp=
an><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </s=
pan><span style=3D"color: rgb(136, 0, 0);">// ...</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><span style=3D"color: rgb(102, 1=
02, 0);">}</span><span style=3D"color: rgb(0, 0, 0);"><br><br>=C2=A0 =C2=A0=
</span><span style=3D"color: rgb(0, 0, 136);">case</span><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">5</spa=
n><font color=3D"#666600"><span style=3D"color: rgb(102, 102, 0);">,</span>=
<span style=3D"color: rgb(0, 0, 0);"> </span></font><span style=3D"color: r=
gb(0, 102, 102);">6</span><span style=3D"color: rgb(102, 102, 0);">:</span>=
<span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);">=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: rgb(136, 0, 0)=
;">// ...</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: r=
gb(0, 0, 0);"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: rgb(0, 0, =
136);">default</span><span style=3D"color: rgb(102, 102, 0);">:</span><span=
style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: rgb(136, 0, 0);">// .=
...</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><spa=
n style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0, 0=
, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">}</span></div></=
code></div><span style=3D"color: rgb(102, 102, 0); font-family: monospace; =
background-color: rgb(250, 250, 250);"><br></span>1. There's no need fo=
r break, there's no fallthrough. Advantage: we can easily "continu=
e" and "break" loops from inside the "switch".</di=
v><div>2. We can use ".." if using several cases that are consecu=
tive in the same block of code, to specify an interval.</div><div><br></div=
><div>I know that it's hard to have features accepted in such a popular=
standard, but upgrading switch is something that should really be consider=
ed ! C++17's [[fallthrough]] attribute is just as complicated as the &q=
uot;switch". It needs to be added everywhere or else we would get warn=
ings (AFAIK).</div><div><br></div><div>C++ needs a lot more syntactic sugar=
.. Small and nice things are making the language more likeable. I think that=
you should watch other languages too for interesting small features.</div>=
</div></div></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/574320af-c1ae-4676-883c-ae4e91fcd874%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/574320af-c1ae-4676-883c-ae4e91fcd874=
%40isocpp.org</a>.<br />
------=_Part_5175_654013518.1502284085717--
------=_Part_5174_1310644540.1502284085716--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 9 Aug 2017 13:08:14 -0400
Raw View
--001a114a826c1ec62b0556552041
Content-Type: text/plain; charset="UTF-8"
break by default is fine, how do I opt-out within switch break, or is it
all or nothing?
switch break(x)
{
case 1:
case 2:
foo();
case 3:
bar();
case 4:
etc();
}
How do I get fallthru on case 1 to 2?
P.S. I think the only way we get a new switch statement is by a big change
- pattern matching.
No one wants to do incremental changes to switch.
But some of these questions need to be answered either way.
P.P.S. to the other question of
>
> switch (s)
> {
> case "A":
> case "B":
> default:
> }
>
I've seen C code do this, where s was a char *. (And s was typically
pointing to static chars, like s = "B")
So you have a pointer s, which is just an int, right?
And all the cases are compile/link time constants...
I'm not sure that was valid C, but it worked. Many years ago.
Tony
On Wed, Aug 9, 2017 at 9:08 AM, <gmisocpp@gmail.com> wrote:
>
> I would very much like to see some changes to switch.
>
> I'd like something like:
>
> switch break (x) // cases break by default;
> {
> case 1: whatever();
> case 2: whatever();
> }
>
> I'd also like, for at least this variation of switch, for a case to be a
> scope by default, such that is ok:
> So that variables can be declared without requiring more braces.
>
> switch break (x) // cases break by default;
> {
> case 1: int z = 1; whatever(z); // not an error
> case 2: whatever();
> }
>
> I think this would make most switch statements a lot less verbose.
> It seems a lot of the flexibility of the classic switch just isn't
> required.
> So this switch could be used when it's not and the existing switch can be
> used when it is.
>
> switch break seems easy to teach to me. So why not?
>
>
>
> On Wednesday, August 2, 2017 at 9:24:04 AM UTC+12, costeln...@gmail.com
> wrote:
>
>> Hello, I'm sorry if you talked about this here before, but I didn't watch
>> this group and I couldn't find this thing when searching.
>>
>> I'm coming from another language named Pawn, it looks like C ~80%, but it
>> has more advantages than C. Here's the official page:
>> https://www.compuphase.com/pawn/pawn.htm .
>>
>> A problem in C++: "switch" is exactly like in C, I think it deserves an
>> upgrade, as it can be used a lot, providing more speed and easier syntax
>> than lots of "if" ... "else if" ... "else" lines. I know that simply
>> updating it would break compatibility, so it may require another name
>> instead of switch, or you can find any other backwards compatible
>> alternative. I bet you can do this perfectly.
>>
>> For cases 0, 1, 2, 3, 4 and 5, 6 and "default" in C++ we have to do it
>> like
>> switch( variable )
>> {
>> case 0: case 1: case 2: case 3: case 4:
>> {
>> // ...
>> break;
>> }
>>
>> case 5: case 6:
>> {
>> // ...
>> break;
>> }
>>
>> default:
>> {
>> // ...
>> }
>> }
>>
>> We have to use "case" for every, well, case when specifying a sequence,
>> because it uses fallthrough. We have to use "break" to avoid that. I find
>> this bad. Because of the necessity of using "break" we can't just "break"
>> out of a loop if the switch is inside a loop. Also, if there are
>> consecutive cases we have to specify each one of them. Additionally, we
>> could also forget breaking. This "switch" isn't safe and is pretty old.
>>
>> In Pawn we can do it a lot better:
>> switch( variable )
>> {
>> case 0 .. 4:
>> {
>> // ...
>> }
>>
>> case 5, 6:
>> {
>> // ...
>> }
>>
>> default:
>> {
>> // ...
>> }
>> }
>>
>> 1. There's no need for break, there's no fallthrough. Advantage: we can
>> easily "continue" and "break" loops from inside the "switch".
>> 2. We can use ".." if using several cases that are consecutive in the
>> same block of code, to specify an interval.
>>
>> I know that it's hard to have features accepted in such a popular
>> standard, but upgrading switch is something that should really be
>> considered ! C++17's [[fallthrough]] attribute is just as complicated as
>> the "switch". It needs to be added everywhere or else we would get warnings
>> (AFAIK).
>>
>> C++ needs a lot more syntactic sugar. Small and nice things are making
>> the language more likeable. I think that you should watch other languages
>> too for interesting small features.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/574320af-c1ae-4676-
> 883c-ae4e91fcd874%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/574320af-c1ae-4676-883c-ae4e91fcd874%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
Be seeing you,
Tony
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbisLgTxLz75Em3Had35AecQrtpRZKFWRaMXUZsSVtN7Fng%40mail.gmail.com.
--001a114a826c1ec62b0556552041
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div><div><div><div><div><div><div><div><div><div><di=
v><div><div><div>break by default is fine, how do I opt-out within switch b=
reak, or is it all or nothing?<br><br></div>switch break(x)<br>{<br></div>c=
ase 1:<br></div>case 2:<br></div>=C2=A0=C2=A0=C2=A0 foo();<br></div>case 3:=
<br></div>=C2=A0=C2=A0=C2=A0 bar();<br></div>case 4:<br></div>=C2=A0=C2=A0=
=C2=A0 etc();<br>=C2=A0}<br><br><br></div>How do I get fallthru on case 1 t=
o 2?<br><br><br></div>P.S. I think the only way we get a new switch stateme=
nt is by a big change - pattern matching.<br></div>No one wants to do incre=
mental changes to switch.<br></div>But some of these questions need to be a=
nswered either way.<br><br></div>P.P.S. to the other question of<br><br><sp=
an class=3D"gmail-im">><br>
> switch (s)<br>
> {<br>
> case "A":<br>
> case "B":<br>
> default:<br>
> }<br>
><br><br></span></div><span class=3D"gmail-im">I've seen C code do t=
his, where s was a char *. (And s was typically pointing to static chars, l=
ike s =3D "B")<br></span></div><span class=3D"gmail-im">So you ha=
ve a pointer s, which is just an int, right?<br>And all the cases are compi=
le/link time constants...<br>I'm not sure that was valid C, but it work=
ed.=C2=A0 Many years ago.<br></span><div><div><br></div><div>Tony<br></div>=
<div><div><div><div><div><div><br></div></div></div></div></div><div class=
=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Aug 9, 2017 at 9:08=
AM, <span dir=3D"ltr"><<a href=3D"mailto:gmisocpp@gmail.com" target=3D=
"_blank">gmisocpp@gmail.com</a>></span> wrote:<br><blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204=
,204,204);padding-left:1ex"><div dir=3D"ltr"><div><br></div><div>I would ve=
ry much like to see some changes to switch.</div><div><br></div><div>I'=
d like something like:</div><div><br></div><div>switch break (x) // cases b=
reak by default;</div><div>{</div><div>=C2=A0=C2=A0=C2=A0 case 1: whatever(=
);</div><div>=C2=A0=C2=A0=C2=A0=C2=A0case 2: whatever();<br>}</div><div><br=
></div><div>I'd also like, for at least this variation of switch,=C2=A0=
for=C2=A0a case=C2=A0to be a scope by default, such that is ok:</div><div>S=
o that variables can be declared without requiring more braces.</div><div><=
br></div><div><div>switch break (x) // cases break by default;</div><div>{<=
/div><div>=C2=A0=C2=A0=C2=A0 case 1: int z =3D 1; whatever(z); // not an er=
ror</div><div>=C2=A0=C2=A0=C2=A0=C2=A0case 2: whatever();<br>}</div><div><b=
r></div><div>I think this would make most switch statements a lot less verb=
ose.</div><div>It seems a lot of the flexibility of the classic switch just=
isn't required.</div><div>So this switch could be used when it's n=
ot and the existing switch can be used when it is.</div><div><br></div><div=
>switch break seems easy to teach to me. So why not?<div><div class=3D"gmai=
l-h5"><br><br><br>On Wednesday, August 2, 2017 at 9:24:04 AM UTC+12, <a hre=
f=3D"mailto:costeln...@gmail.com" target=3D"_blank">costeln...@gmail.com</a=
> wrote:</div></div></div></div><div><div class=3D"gmail-h5"><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;bord=
er-left:1px solid rgb(204,204,204)"><div dir=3D"ltr">Hello, I'm sorry i=
f you talked about this here before, but I didn't watch this group and =
I couldn't find this thing when searching.<div><br></div><div>I'm c=
oming from another language named Pawn, it looks like C ~80%, but it has mo=
re advantages than C. Here's the official page:=C2=A0<a href=3D"https:/=
/www.compuphase.com/pawn/pawn.htm" rel=3D"nofollow" target=3D"_blank">https=
://www.compuphase.c<wbr>om/pawn/pawn.htm</a> .</div><div><br></div><div>A p=
roblem in C++: "switch" is exactly like in C, I think it deserves=
an upgrade, as it can be used a lot, providing more speed and easier synta=
x than lots of "if" ... "else if" ... "else" =
lines. I know that simply updating it would break compatibility, so it may =
require another name instead of switch, or you can find any other backwards=
compatible alternative. I bet you can do this perfectly.<div><br></div><di=
v>For cases 0, 1, 2, 3, 4 and 5, 6 and "default" in C++ we have t=
o do it like</div><div style=3D"border-width:1px;border-style:solid;border-=
color:rgb(187,187,187);background-color:rgb(250,250,250)"><code><div><span =
style=3D"color:rgb(0,0,136)">switch</span><span style=3D"color:rgb(102,102,=
0)">(</span><span style=3D"color:rgb(0,0,0)"> variable </span><span style=
=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"><br></sp=
an><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,=
0,0)"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">case</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,1=
02)">0</span><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"co=
lor:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">case</span><span=
style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">1<=
/span><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">case</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">2</span>=
<span style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,0,0=
)"> </span><span style=3D"color:rgb(0,0,136)">case</span><span style=3D"col=
or:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">3</span><span s=
tyle=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,0,0)"> </s=
pan><span style=3D"color:rgb(0,0,136)">case</span><span style=3D"color:rgb(=
0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">4</span><span style=3D=
"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"c=
olor:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"colo=
r:rgb(136,0,0)">// ...</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">break</span>=
<span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0=
)"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><s=
pan style=3D"color:rgb(0,0,0)"><br><br>=C2=A0 =C2=A0 </span><span style=3D"=
color:rgb(0,0,136)">case</span><span style=3D"color:rgb(0,0,0)"> </span><sp=
an style=3D"color:rgb(0,102,102)">5</span><span style=3D"color:rgb(102,102,=
0)">:</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:r=
gb(0,0,136)">case</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(0,102,102)">6</span><span style=3D"color:rgb(102,102,0)">:</=
span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(136,0,0)">// ...</=
span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </spa=
n><span style=3D"color:rgb(0,0,136)">break</span><span style=3D"color:rgb(1=
02,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </spa=
n><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0=
,0)"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">defaul=
t</span><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:r=
gb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">{<=
/span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </sp=
an><span style=3D"color:rgb(136,0,0)">// ...</span><span style=3D"color:rgb=
(0,0,0)"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</s=
pan><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(10=
2,102,0)">}</span></div></code></div><div><br></div><div>We have to use &qu=
ot;case" for every, well, case when specifying a sequence, because it =
uses fallthrough. We have to use "break" to avoid that. I find th=
is bad. Because of the necessity of using "break" we can't ju=
st "break" out of a loop if the switch is inside a loop. Also, if=
there are consecutive cases we have to specify each one of them. Additiona=
lly, we could also forget breaking. This "switch" isn't safe =
and is pretty old.</div><div><br></div><div>In Pawn we can do it a lot bett=
er:</div><div><div style=3D"border-width:1px;border-style:solid;border-colo=
r:rgb(187,187,187);background-color:rgb(250,250,250)"><code><div><span styl=
e=3D"color:rgb(0,0,136)">switch</span><span style=3D"color:rgb(102,102,0)">=
(</span><span style=3D"color:rgb(0,0,0)"> variable </span><span style=3D"co=
lor:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"><br></span><sp=
an style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">case</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">0=
</span><font color=3D"#666600"><span style=3D"color:rgb(0,0,0)"> </span><sp=
an style=3D"color:rgb(102,102,0)">..</span><span style=3D"color:rgb(0,0,0)"=
> </span></font><span style=3D"color:rgb(0,102,102)">4</span><span style=3D=
"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"c=
olor:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"colo=
r:rgb(136,0,0)">// ...</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,=
136)">case</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(0,102,102)">5</span><font color=3D"#666600"><span style=3D"color:rg=
b(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span></font><span=
style=3D"color:rgb(0,102,102)">6</span><span style=3D"color:rgb(102,102,0)=
">:</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(136,0,0)">// ..=
..</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">default</span><sp=
an style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,0,0)">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">{</span><span=
style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span st=
yle=3D"color:rgb(136,0,0)">// ...</span><span style=3D"color:rgb(0,0,0)"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span s=
tyle=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">}=
</span></div></code></div><span style=3D"color:rgb(102,102,0);font-family:m=
onospace;background-color:rgb(250,250,250)"><br></span>1. There's no ne=
ed for break, there's no fallthrough. Advantage: we can easily "co=
ntinue" and "break" loops from inside the "switch"=
..</div><div>2. We can use ".." if using several cases that are co=
nsecutive in the same block of code, to specify an interval.</div><div><br>=
</div><div>I know that it's hard to have features accepted in such a po=
pular standard, but upgrading switch is something that should really be con=
sidered ! C++17's [[fallthrough]] attribute is just as complicated as t=
he "switch". It needs to be added everywhere or else we would get=
warnings (AFAIK).</div><div><br></div><div>C++ needs a lot more syntactic =
sugar. Small and nice things are making the language more likeable. I think=
that you should watch other languages too for interesting small features.<=
/div></div></div></blockquote></div></div></div><div><div class=3D"gmail-h5=
">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/574320af-c1ae-4676-883c-ae4e91fcd874%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/5743=
20af-c1ae-4676-<wbr>883c-ae4e91fcd874%40isocpp.org</a><wbr>.<br>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature"><div dir=3D"ltr"><div>Be seeing you,<br></div>Tony<br></div></div>
</div></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbisLgTxLz75Em3Had35AecQrtpRZKFWR=
aMXUZsSVtN7Fng%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbisLgTxLz75E=
m3Had35AecQrtpRZKFWRaMXUZsSVtN7Fng%40mail.gmail.com</a>.<br />
--001a114a826c1ec62b0556552041--
.
Author: Olaf van der Spek <olafvdspek@gmail.com>
Date: Wed, 9 Aug 2017 19:40:38 +0200
Raw View
2017-08-09 19:08 GMT+02:00 Tony V E <tvaneerd@gmail.com>:
>> switch (s)
>> {
>> case "A":
>> case "B":
>> default:
>> }
>>
>
> I've seen C code do this, where s was a char *. (And s was typically
> pointing to static chars, like s = "B")
> So you have a pointer s, which is just an int, right?
> And all the cases are compile/link time constants...
> I'm not sure that was valid C, but it worked. Many years ago.
Ah, so all I need to do is switch (s.c_str())? ;)
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAA7U3HNS9zbt3HnOQYjgpRDvU3czYFgdPDfOo%3DV%3D8WmKB%2ByQOA%40mail.gmail.com.
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 09 Aug 2017 12:38:43 -0700
Raw View
On quarta-feira, 9 de agosto de 2017 10:08:14 PDT Tony V E wrote:
> So you have a pointer s, which is just an int, right?
> And all the cases are compile/link time constants...
> I'm not sure that was valid C, but it worked. Many years ago.
>
> Tony
Something like this?
switch ("A") {
case "A":
return 0;
case "B":
return 1;
default:
return 2;
}
It doesn't compile in C: https://godbolt.org/g/m9Asnk (Clang) &
https://godbolt.org/g/Uy1pKW (GCC)
Even if it did, what do you think this would return? I'd say it's equally
correct to return 0 or 2.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/41733595.o4GQ0c89LU%40tjmaciei-mobl1.
.
Author: Constantin-Flavius Nistor <costelnistor12@gmail.com>
Date: Wed, 9 Aug 2017 12:42:50 -0700 (PDT)
Raw View
------=_Part_95_1937592132.1502307770457
Content-Type: multipart/alternative;
boundary="----=_Part_96_1631201143.1502307770458"
------=_Part_96_1631201143.1502307770458
Content-Type: text/plain; charset="UTF-8"
On Wednesday, 2 August 2017 09:19:39 UTC+3, wei zhang wrote:
>
> We can only add silently with case 5, 6:
>
I know that, probably the ".." or "..." range thing too.
On Wednesday, 9 August 2017 16:08:05 UTC+3, gmis...@gmail.com wrote:
>
>
> I would very much like to see some changes to switch.
>
> I'd like something like:
>
> switch break (x) // cases break by default;
> {
> case 1: whatever();
> case 2: whatever();
> }
>
> I'd also like, for at least this variation of switch, for a case to be a
> scope by default, such that is ok:
> So that variables can be declared without requiring more braces.
>
> switch break (x) // cases break by default;
> {
> case 1: int z = 1; whatever(z); // not an error
> case 2: whatever();
> }
>
> I think this would make most switch statements a lot less verbose.
> It seems a lot of the flexibility of the classic switch just isn't
> required.
> So this switch could be used when it's not and the existing switch can be
> used when it is.
>
> switch break seems easy to teach to me. So why not?
>
I actually like this idea ! "switch break" could be just right for this. It
wouldn't break backwards compatibility.
On Wednesday, 2 August 2017 17:58:42 UTC+3, Matthew Woehlke wrote:
>
> > 1. There's no need for break, there's no fallthrough. Advantage: we can
> > easily "continue" and "break" loops from inside the "switch".
>
> Disadvantage: you can't do this:
>
> case FOO:
> ...some code...
> [[fallthrough]];
> case BAR:
> ...more code...
> break;
>
> And yes, I've actually written code like that before.
>
> --
> Matthew
On Wednesday, 9 August 2017 20:08:18 UTC+3, Tony V E wrote:
>
> break by default is fine, how do I opt-out within switch break, or is it
> all or nothing?
>
> switch break(x)
> {
> case 1:
> case 2:
> foo();
> case 3:
> bar();
> case 4:
> etc();
> }
>
>
> How do I get fallthru on case 1 to 2?
>
Well, for this we could use the current style switch. Or the [[fallthrough]]
attribute could behave differently in a "switch break", it could enable the
fallthrough there instead of only announcing it, if possible.
About the other too complex suggestions: I don't think that something
similar to "case v = (50,...) // 50 < v" could be made reliably, I don't
really know how jump tables really work, but I think that they work only
for integers (so no possibility to use directly std::string ! probably only
if it will get hashed into an int, but it will be faster than "if/else
if/else" only if it would have many cases), without the possibility to
actually check intervals, so a thing like "1..6" would actually expand to
all those cases individually, it would only allow us to write it faster. It
could give us a lot of benefits in these cases:
C++:
switch( someinteger )
{
case 581: case 523: case 462: case 521: case 463: case 522: case 461:
case 448: case 468: case 586:
case 509: case 481: case 510: case 472: case 473: case 493: case 595:
case 484: case 430: case 453:
case 452: case 446: case 454: case 590: case 569: case 537: case 538:
case 570: case 449: case 513:
case 520: case 519: case 487: case 417: case 406: case 556: case 444:
case 557:
return 1;
}
Pawn (my proposal):
switch( someinteger )
{
case 581, 523, 462, 521, 463, 522, 461, 448, 468, 586, 509, 481, 510,
472, 473, 493, 595, 484, 430, 453,
452, 446, 454, 590, 569, 537, 538, 570, 449, 513, 520, 519, 487,
417, 406, 556, 444, 557:
return 1;
}
And this could get a lot better, example:
C++:
// inside some function
for( unsigned int i = 0; i < liLength; i ++ )
{
switch( lsString[ i ] )
{
case '0': case '1': case '2': ...etc... case 'a': case 'b': ... etc ...
case 'X': case 'Y': case 'Z':
case '[': case ']': case '(': case ')': case '$': case '@':
case '.': case '_': case '=': break;
default: return false;
}
}
Pawn (my proposal):
// inside some function
for( new i = 0; i < liLength; i ++ )
{
switch( lsString[ i ] )
{
case '0' .. '9', 'a' .. 'z', 'A' .. 'Z', '[', ']', '(', ')', '$',
'@', '.', '_', '=': { }
default: return 0;
}
}
It would get expanded at compile time. It's a lot nicer.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b73a0c61-6f73-4eb6-bb30-87c8bbefe2a4%40isocpp.org.
------=_Part_96_1631201143.1502307770458
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, 2 August 2017 09:19:39 UTC+3, wei zhang wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; bor=
der-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir=3D"ltr=
">We can only add silently with case 5, 6:</div></blockquote><div><br></div=
><div>I know that, probably the ".." or "..." range thi=
ng too.</div><div><br></div><div><br></div><div>On Wednesday, 9 August 2017=
16:08:05 UTC+3, gmis...@gmail.com wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 20=
4); padding-left: 1ex;"><div dir=3D"ltr"><div><br></div><div>I would very m=
uch like to see some changes to switch.</div><div><br></div><div>I'd li=
ke something like:</div><div><br></div><div>switch break (x) // cases break=
by default;</div><div>{</div><div>=C2=A0=C2=A0=C2=A0 case 1: whatever();</=
div><div>=C2=A0=C2=A0=C2=A0=C2=A0case 2: whatever();<br>}</div><div><br></d=
iv><div>I'd also like, for at least this variation of switch,=C2=A0for=
=C2=A0a case=C2=A0to be a scope by default, such that is ok:</div><div>So t=
hat variables can be declared without requiring more braces.</div><div><br>=
</div><div><div>switch break (x) // cases break by default;</div><div>{</di=
v><div>=C2=A0=C2=A0=C2=A0 case 1: int z =3D 1; whatever(z); // not an error=
</div><div>=C2=A0=C2=A0=C2=A0=C2=A0case 2: whatever();<br>}</div><div><br><=
/div><div>I think this would make most switch statements a lot less verbose=
..</div><div>It seems a lot of the flexibility of the classic switch just is=
n't required.</div><div>So this switch could be used when it's not =
and the existing switch can be used when it is.</div><div><br></div><div>sw=
itch break seems easy to teach to me. So why not?</div></div></div></blockq=
uote><div>I actually like this idea ! "switch break" could be jus=
t right for this. It wouldn't break backwards compatibility.=C2=A0</div=
><div><br></div><div><br></div>On Wednesday, 2 August 2017 17:58:42 UTC+3, =
Matthew Woehlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0p=
x 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1=
ex;">> 1. There's no need for break, there's no fallthrough. Adv=
antage: we can=C2=A0<br>> easily "continue" and "break&qu=
ot; loops from inside the "switch".=C2=A0<br><br>Disadvantage: yo=
u can't do this:=C2=A0<br><br>=C2=A0 case FOO:=C2=A0<br>=C2=A0 =C2=A0 .=
...some code...=C2=A0<br>=C2=A0 =C2=A0 [[fallthrough]];=C2=A0<br>=C2=A0 case=
BAR:=C2=A0<br>=C2=A0 =C2=A0 ...more code...=C2=A0<br>=C2=A0 =C2=A0 break;=
=C2=A0<br><br>And yes, I've actually written code like that before.=C2=
=A0<br><br>--=C2=A0<br>Matthew=C2=A0</blockquote><div>=C2=A0</div><div>On W=
ednesday, 9 August 2017 20:08:18 UTC+3, Tony V E wrote:<blockquote class=3D=
"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rg=
b(204, 204, 204); padding-left: 1ex;"><div dir=3D"ltr"><div><div><div><div>=
<div><div><div><div><div>break by default is fine, how do I opt-out within =
switch break, or is it all or nothing?<br><br></div>switch break(x)<br>{<br=
></div>case 1:<br></div>case 2:<br></div>=C2=A0=C2=A0=C2=A0 foo();<br></div=
>case 3:<br></div>=C2=A0=C2=A0=C2=A0 bar();<br></div>case 4:<br></div>=C2=
=A0=C2=A0=C2=A0 etc();<br>=C2=A0}<br><br><br></div>How do I get fallthru on=
case 1 to 2?</div></blockquote><div>=C2=A0</div></div><div>Well, for this =
we could use the current style switch. Or the<font color=3D"#000000">=C2=A0=
[[fallthrough]] attribute could behave differently in a "switch break&=
quot;, it could enable the fallthrough there instead of only announcing it,=
if possible.</font></div></div><div><font color=3D"#000000"><br></font></d=
iv><div><font color=3D"#000000"><br></font></div><div><font color=3D"#00000=
0">About the other too complex suggestions: I don't think that somethin=
g similar to "</font><span style=3D"font-family: arial, sans-serif; fo=
nt-size: 12.8px;">case v =3D (50,...) // 50 < v" could be made reli=
ably, I don't really know how jump tables really work, but I think that=
they work only for integers (so no possibility to use directly std::string=
! probably only if it will get hashed into an int, but it will be faster t=
han "if/else if/else" only if it would have many cases), without =
the possibility to actually check intervals, so a thing like "1..6&quo=
t; would actually expand to all those cases individually, it would only all=
ow us to write it faster. It could give us a lot of benefits in these cases=
:</span></div><div><span style=3D"font-family: arial, sans-serif; font-size=
: 12.8px;"><br></span></div><div><span style=3D"font-family: arial, sans-se=
rif; font-size: 12.8px;">C++:</span></div><div><div class=3D"prettyprint" s=
tyle=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 1=
87); border-style: solid; border-width: 1px; word-wrap: break-word;"><code =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">switch</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> someinteger </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">case</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">581<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">case</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">523</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">case</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">462</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">case</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">521</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">case</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">463</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">case</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">522</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
ase</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">461</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">448</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">case</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">468</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">586</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;"=
class=3D"styled-by-prettify">=C2=A0 =C2=A0 </span></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">case</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">509</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>case</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">481</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">case</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">510</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
ase</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">472</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">473</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">case</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">493</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">595</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">484</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">430</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">453</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: rgb(0, 0, 0=
);"><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0=
</span></span><span style=3D"color: #008;" class=3D"styled-by-prettify">ca=
se</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">452</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"st=
yled-by-prettify">446</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">case</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #066;" class=3D"styled-by-prettify">454</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">590</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">569</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">537</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">538</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">570</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">449</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">case</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pretti=
fy">513</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><=
span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">=C2=A0 =C2=A0 </span></span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">520</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">519</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">487</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">417</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">case</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">406</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">case</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">556</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">case</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pretti=
fy">444</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">case</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">557</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: rgb(0, 0, 0);"><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0=C2=A0<=
/span></span><span style=3D"color: rgb(0, 0, 0); font-family: Arial, Helvet=
ica, sans-serif;">=C2=A0 =C2=A0</span><span style=3D"color: rgb(0, 0, 0); f=
ont-family: Arial, Helvetica, sans-serif;">=C2=A0</span><span class=3D"styl=
ed-by-prettify" style=3D"font-family: Arial, Helvetica, sans-serif; color: =
rgb(0, 0, 136);">return</span><span class=3D"styled-by-prettify" style=3D"f=
ont-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);"> </span><sp=
an class=3D"styled-by-prettify" style=3D"font-family: Arial, Helvetica, san=
s-serif; color: rgb(0, 102, 102);">1</span><span class=3D"styled-by-prettif=
y" style=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(102, 102,=
0);">;</span></div><div class=3D"subprettyprint"><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span></div></code></div><div style=3D""=
><font face=3D"arial, sans-serif"><span style=3D"font-size: 12.8px;"><br></=
span></font></div></div><div>Pawn (my proposal):</div><div><div class=3D"pr=
ettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb=
(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-w=
ord;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">switch</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> someinteger </span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify"><span style=3D"color: rgb(0, 0, 0);">=C2=A0 =C2=A0=C2=A0</span>cas=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">581</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">523</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">462</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">521</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">463</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">522</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">461</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">448</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">468</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">586</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">509</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">481</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">510</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">472</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">473</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">493</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">595</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">484</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">430</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">453</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">452</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">446</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">454</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">590</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">569</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">537</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">538</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">570</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">449</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">513</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">520</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">519</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">487</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">417</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">406</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">556</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">444</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">557</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"" class=3D"styled-by-prettify"><font color=3D"#000000">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</font></span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"st=
yled-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</spa=
n></div></code></div><div><br></div></div><div>And this could get a lot bet=
ter, example:</div><div><br></div><div>C++:</div><div><div class=3D"prettyp=
rint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187,=
187, 187); border-style: solid; border-width: 1px; word-wrap: break-word;"=
><code class=3D"prettyprint"><div class=3D"subprettyprint"><font color=3D"#=
000088"><div class=3D"subprettyprint">// inside some function</div><div cla=
ss=3D"subprettyprint"><br></div><div class=3D"subprettyprint">for( unsigned=
int i =3D 0; i < liLength; i ++ )</div><div class=3D"subprettyprint">{<=
/div><div class=3D"subprettyprint">=C2=A0 =C2=A0 switch( lsString[ i ] )</d=
iv><div class=3D"subprettyprint">=C2=A0 =C2=A0 {</div><div class=3D"subpret=
typrint"><span style=3D"white-space:pre"> </span>case '0': case &#=
39;1': case '2': ...etc... case 'a': case 'b': =
.... etc ... case 'X': case 'Y': case 'Z':</div><div=
class=3D"subprettyprint"><span style=3D"white-space:pre"> </span>case &#=
39;[': case ']': case '(': case ')': case '=
$': case '@':</div><div class=3D"subprettyprint"><span style=3D=
"white-space:pre"> </span>case '.': case '_': case '=
=3D': break;<br><br></div><div class=3D"subprettyprint"><span style=3D"=
white-space:pre"> </span>default: return false;</div><div class=3D"subpret=
typrint"><span style=3D"white-space:pre"> </span>}</div><div class=3D"subpr=
ettyprint">}</div></font></div></code></div><div><br></div></div><div>Pawn =
(my proposal):</div><div><div class=3D"prettyprint" style=3D"background-col=
or: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: sol=
id; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">// inside some function<br><br>for</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">new</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> i </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> i </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> liLength</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> i </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">++</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"" class=3D"styled-by-prettify"><font color=3D"#000000">=C2=A0 =C2=A0=C2=
=A0</font></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
switch</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> lsString</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> i </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"><span style=3D"color: rgb(0, 0, 0);">=C2=A0 =C2=A0=C2=A0</spa=
n>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify"><span style=
=3D"color: rgb(0, 0, 0);">=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</span>case</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">'0'</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">..</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" cla=
ss=3D"styled-by-prettify">'9'</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">'a'</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>..</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #080;" class=3D"styled-by-prettify">'z'</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #080;" class=3D"styled-by-prettify">'A'</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">..</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"sty=
led-by-prettify">'Z'</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
'['</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">']'</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #080;" class=3D"styled-by-prettify">'('</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">')'</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pre=
ttify">'$'</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #080;" class=3D"styled-by-prettify">'@'=
;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #080;" class=3D"styled-by-prettify">'.'</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;=
" class=3D"styled-by-prettify">'_'</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">'=3D'</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify"><span style=3D"color: rgb(0, 0, 0=
);">=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</span>default</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><span style=
=3D"color: rgb(0, 0, 0);">=C2=A0 =C2=A0=C2=A0</span>}</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">}</span></div></code></div><div><br></=
div></div><div>It would get expanded at compile time. It's a lot nicer.=
</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b73a0c61-6f73-4eb6-bb30-87c8bbefe2a4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b73a0c61-6f73-4eb6-bb30-87c8bbefe2a4=
%40isocpp.org</a>.<br />
------=_Part_96_1631201143.1502307770458--
------=_Part_95_1937592132.1502307770457--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 9 Aug 2017 16:17:07 -0400
Raw View
--001a1140c548a28efe055657c3b9
Content-Type: text/plain; charset="UTF-8"
On Wed, Aug 9, 2017 at 3:38 PM, Thiago Macieira <thiago@macieira.org> wrote:
> On quarta-feira, 9 de agosto de 2017 10:08:14 PDT Tony V E wrote:
> > So you have a pointer s, which is just an int, right?
> > And all the cases are compile/link time constants...
> > I'm not sure that was valid C, but it worked. Many years ago.
> >
> > Tony
>
> Something like this?
>
> switch ("A") {
> case "A":
> return 0;
> case "B":
> return 1;
> default:
> return 2;
> }
>
> It doesn't compile in C: https://godbolt.org/g/m9Asnk (Clang) &
> https://godbolt.org/g/Uy1pKW (GCC)
>
> Even if it did, what do you think this would return? I'd say it's equally
> correct to return 0 or 2.
>
>
yep, basically.
Once upon a time some compiler compiled that, and I agree, I wouldn't
guarantee what it returned.
(I think the idea was that hitting the "A" case was an optimization, and
case default was to do a strcmp())
This was more than 20 years ago.
Oh my. Maybe 30 years ago.
But that doesn't mean "more than 20" is incorrect, so I'll just keep
telling myself "20", I've coded for 20+ years.
Tony
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbiv6n3oFG9Xj%2BQgPRhwdN2xDUV0zZvtYXXiALOXE3vOUhA%40mail.gmail.com.
--001a1140c548a28efe055657c3b9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, Aug 9, 2017 at 3:38 PM, Thiago Macieira <span dir=3D"ltr"><<=
a href=3D"mailto:thiago@macieira.org" target=3D"_blank">thiago@macieira.org=
</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin=
:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">O=
n quarta-feira, 9 de agosto de 2017 10:08:14 PDT Tony V E wrote:<br>
> So you have a pointer s, which is just an int, right?<br>
> And all the cases are compile/link time constants...<br>
> I'm not sure that was valid C, but it worked.=C2=A0 Many years ago=
..<br>
><br>
> Tony<br>
<br>
</span>Something like this?<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 switch ("A") {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case "A":<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case "B":<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 default:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 2;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>
<br>
It doesn't compile in C: <a href=3D"https://godbolt.org/g/m9Asnk" rel=
=3D"noreferrer" target=3D"_blank">https://godbolt.org/g/m9Asnk</a> (Clang) =
&<br>
<a href=3D"https://godbolt.org/g/Uy1pKW" rel=3D"noreferrer" target=3D"_blan=
k">https://godbolt.org/g/Uy1pKW</a> (GCC)<br>
<br>
Even if it did, what do you think this would return? I'd say it's e=
qually<br>
correct to return 0 or 2.<br>
<span class=3D""><br></span></blockquote><div><br><br></div><div>yep, basic=
ally.<br><br></div><div>Once upon a time some compiler compiled that, and I=
agree, I wouldn't guarantee what it returned.<br></div><div>(I think t=
he idea was that hitting the "A" case was an optimization, and ca=
se default was to do a strcmp())<br><br></div><div>This was more than 20 ye=
ars ago.<br></div><div>Oh my. Maybe 30 years ago.<br></div></div><div class=
=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div>But that doesn=
't mean "more than 20" is incorrect, so I'll just keep te=
lling myself "20", I've coded for 20+ years.<br><br>Tony<br><=
/div><div><br></div></div>
</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbiv6n3oFG9Xj%2BQgPRhwdN2xDUV0zZv=
tYXXiALOXE3vOUhA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbiv6n3oFG9=
Xj%2BQgPRhwdN2xDUV0zZvtYXXiALOXE3vOUhA%40mail.gmail.com</a>.<br />
--001a1140c548a28efe055657c3b9--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 09 Aug 2017 13:29:43 -0700
Raw View
On quarta-feira, 9 de agosto de 2017 13:17:07 PDT Tony V E wrote:
> yep, basically.
>
> Once upon a time some compiler compiled that, and I agree, I wouldn't
> guarantee what it returned.
> (I think the idea was that hitting the "A" case was an optimization, and
> case default was to do a strcmp())
Like multicharacter literals?
int v = 'abcd';
GCC and ICC warn about that by default. Clang only warns at -Wpedantic. MSVC
does not warn even at -W4.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1532678.cu6QfydWbQ%40tjmaciei-mobl1.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 9 Aug 2017 16:37:09 -0400
Raw View
--001a114cb1b84e36da0556580b0c
Content-Type: text/plain; charset="UTF-8"
On Wed, Aug 9, 2017 at 4:29 PM, Thiago Macieira <thiago@macieira.org> wrote:
> On quarta-feira, 9 de agosto de 2017 13:17:07 PDT Tony V E wrote:
> > yep, basically.
> >
> > Once upon a time some compiler compiled that, and I agree, I wouldn't
> > guarantee what it returned.
> > (I think the idea was that hitting the "A" case was an optimization, and
> > case default was to do a strcmp())
>
> Like multicharacter literals?
> int v = 'abcd';
>
> GCC and ICC warn about that by default. Clang only warns at -Wpedantic.
> MSVC
> does not warn even at -W4.
>
>
No really, case "a literal string":
It was the wild west of compiling, before even C was a standard.
So really, maybe this isn't pertinent information to the current
discussion, but it has been stuck in my head all these years.
--
Be seeing you,
Tony
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbitVe3%2BTZNqcdSyhORbjxABddavdZ5EGyi4zcO025t%2BcjQ%40mail.gmail.com.
--001a114cb1b84e36da0556580b0c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, Aug 9, 2017 at 4:29 PM, Thiago Macieira <span dir=3D"ltr"><<=
a href=3D"mailto:thiago@macieira.org" target=3D"_blank">thiago@macieira.org=
</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin=
:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">O=
n quarta-feira, 9 de agosto de 2017 13:17:07 PDT Tony V E wrote:<br>
> yep, basically.<br>
><br>
> Once upon a time some compiler compiled that, and I agree, I wouldn=
9;t<br>
> guarantee what it returned.<br>
> (I think the idea was that hitting the "A" case was an optim=
ization, and<br>
> case default was to do a strcmp())<br>
<br>
</span>Like multicharacter literals?<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 int v =3D 'abcd';<br>
<br>
GCC and ICC warn about that by default. Clang only warns at -Wpedantic. MSV=
C<br>
does not warn even at -W4.<br>
<span class=3D""><br></span></blockquote><div><br></div><div>No really, cas=
e "a literal string": <br></div><div>It was the wild west of comp=
iling, before even C was a standard.<br><br clear=3D"all"></div></div>So re=
ally, maybe this isn't pertinent information to the current discussion,=
but it has been stuck in my head all these years.<br></div><div class=3D"g=
mail_extra">-- <br><div class=3D"gmail_signature" data-smartmail=3D"gmail_s=
ignature"><div dir=3D"ltr"><div>Be seeing you,<br></div>Tony<br></div></div=
>
</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbitVe3%2BTZNqcdSyhORbjxABddavdZ5=
EGyi4zcO025t%2BcjQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbitVe3%2=
BTZNqcdSyhORbjxABddavdZ5EGyi4zcO025t%2BcjQ%40mail.gmail.com</a>.<br />
--001a114cb1b84e36da0556580b0c--
.
Author: Cleiton Santoia <cleitonsantoia@gmail.com>
Date: Wed, 9 Aug 2017 16:29:11 -0700 (PDT)
Raw View
------=_Part_290_1863104350.1502321351131
Content-Type: multipart/alternative;
boundary="----=_Part_291_1921638203.1502321351132"
------=_Part_291_1921638203.1502321351132
Content-Type: text/plain; charset="UTF-8"
> That's not a switch, that's an if-else chain masquerading as a switch.
> I would strongly
> suggest adding a pattern-matching mechanism and leaving switch alone;
> switch has
> semantics that don't fit into general matching, and other expectations
> that a general
> matching mechanism doesn't have, including recommendations against using
> switch
> because switch does fall-through and a general matching mechanism
> probably shouldn't.
>
This is good...
I want a *gmm* (general matching mechanism) and I think that the keyword
for it should be *switch*.
Said that, now we need to a way to tell the compiler that we are talking
about the "new" switch, maybe via positional token ( megazord ), analogous
to "switch break" already mentioned.
This switch will apply to more than one expression at a time, and use "=="
for each element and "default break" unless you specify via [[fallthrough]]
std::string x = "AF-56";
enum YesNo{ NO,YES } answer = YesNo.YES;
switch megazord ( answer; int k = 90; x.substr(0,2) ) {
case NO; default : // enters here if answer is NO and not check any of the
others
// Code
case YES; 10r.100r; "[_a-zA-Z][_a-zA-Z0-9]{0,30}"regex : // ranges and
regular expressions, nice !
// Code
case YES; 10r.100r; "AA"r."AX"r : // ranges can be of std::strings too ( or
const char* ), why not ?
// Code
case default:
}
I think this covers almost all problems:
1 - Can be used with std::string ( or anything else: std::variant,
std::string_view, std::vector )
2 - Can be used with ranges ( analogous to ".." operator ). I wonder... can
I use two unary postfix "dot" operator in a sequence ?
3 - Can be used with many arguments at once.
4 - Execute functions, make temporaries and declare variables at the
beginning
5 - Avoid unintentional fallthrough
6 - Leave the old switch alone
But still get the problem :
switch megazord ("A") { // this is a const char * pointer and one cannot
overload ''=="
}
We need
switch megazord("A"s) { // <- string literal
}
P.S. I know... I know... megazord is not a good name, may be 'batman'
instead
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/cb29f028-f791-4cb7-8593-5683995839f3%40isocpp.org.
------=_Part_291_1921638203.1502321351132
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">That'=
s not a switch, that's an if-else chain masquerading as a switch.
<br>I would strongly
<br>suggest adding a pattern-matching mechanism and leaving switch alone; s=
witch has
<br>semantics that don't fit into general matching, and other expectati=
ons
<br>that a general
<br>matching mechanism doesn't have, including recommendations against =
using switch
<br>because switch does fall-through and a general matching mechanism
<br>probably shouldn't.
<br></blockquote><div><br></div><div>This is good...</div><div>I want a *gm=
m* (general matching mechanism) and I think that the keyword for it should =
be <b>switch</b>.</div><div><br></div><div>Said that, now we need to a way =
to tell the compiler that we are talking about the "new" switch, =
maybe via positional token ( megazord ), analogous to "switch break&qu=
ot; already mentioned.=C2=A0</div><div><br></div><div>This switch will appl=
y to more than one expression at a time, and use "=3D=3D" for eac=
h element and "default break" unless you specify via [[fallthroug=
h]]<br></div><div><br></div><div><br></div><div><div class=3D"prettyprint" =
style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, =
187); border-style: solid; border-width: 1px; word-wrap: break-word;"><code=
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: =
rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify">st=
d</span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">::</span></span><span style=3D"color=
: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">string</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> x </span></span><span style=3D"c=
olor: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span style=
=3D"color: rgb(0, 136, 0);"><span style=3D"color: #080;" class=3D"styled-by=
-prettify">"AF-56"</span></span><span style=3D"color: rgb(102, 10=
2, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><=
/span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span></span><span style=3D"color: rgb(0, 0,=
136);"><span style=3D"color: #008;" class=3D"styled-by-prettify">enum</spa=
n></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span></span><span style=3D"color: rgb(102, =
0, 102);"><span style=3D"color: #606;" class=3D"styled-by-prettify">YesNo</=
span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span></span><span style=3D"color: rg=
b(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> NO<=
/span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color:=
#660;" class=3D"styled-by-prettify">,</span></span><span style=3D"color: r=
gb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify">YES=
</span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">}</span></span><span style=3D"color:=
rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
answer </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0</sp=
an></span><span style=3D"color: rgb(102, 0, 102); font-family: Arial, Helve=
tica, sans-serif;">YesNo.YES</span><span style=3D"color: rgb(102, 102, 0); =
font-family: Arial, Helvetica, sans-serif;">;</span></div><div class=3D"sub=
prettyprint"><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span></span><span style=3D"color: rg=
b(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-prettify">sw=
itch</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color=
: #000;" class=3D"styled-by-prettify">=C2=A0megazord=C2=A0</span></span><sp=
an style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span></span><span style=3D"color: rgb(0, 0, 0);" cl=
ass=3D"styled-by-prettify"> answer</span><span style=3D"" class=3D"styled-b=
y-prettify"><font color=3D"#666600">;</font></span><span style=3D"color: rg=
b(0, 0, 0);" class=3D"styled-by-prettify">=C2=A0int k =3D 90</span><span st=
yle=3D"" class=3D"styled-by-prettify"><font color=3D"#666600">;</font></spa=
n><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">=C2=A0x</span></span><span style=3D"color: rgb(102,=
102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" =
class=3D"styled-by-prettify">substr</span></span><span style=3D"color: rgb(=
102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span></span><span style=3D"color: rgb(0, 102, 102);"><span style=3D"color:=
#066;" class=3D"styled-by-prettify">0</span></span><span style=3D"color: r=
gb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span></span><span style=3D"color: rgb(0, 102, 102);"><span style=3D"col=
or: #066;" class=3D"styled-by-prettify">2</span></span><span style=3D"color=
: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span></span><span style=3D"color:=
rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span></span><span style=3D"color: =
rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br></span></span><span style=3D"color=
: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">case</span></span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by=
-prettify"> NO</span><span style=3D"" class=3D"styled-by-prettify"><font co=
lor=3D"#666600">;</font></span><span style=3D"color: rgb(0, 0, 0);"><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0</span></span><spa=
n style=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">default</span></span><span style=3D"color: rgb(0, 0, 0);"=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><=
span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span></span><span style=3D"color: rgb(0, 0, 0);"=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><=
span style=3D"color: rgb(136, 0, 0);"><span style=3D"color: #800;" class=3D=
"styled-by-prettify">// enters here if answer is NO and not check any of th=
e others</span></span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-=
by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"" class=3D"styled-by-p=
rettify"><font color=3D"#000088">// Code</font></span><span style=3D"color:=
rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span></span><span style=3D"color: rgb(0, 0, 136);"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">case</span></span><span style=3D"col=
or: rgb(0, 0, 0);" class=3D"styled-by-prettify"> YES</span><span style=3D""=
class=3D"styled-by-prettify"><font color=3D"#666600">;</font></span><span =
style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">=C2=A0</span><s=
pan style=3D"" class=3D"styled-by-prettify"><font color=3D"#006666">10r.100=
r</font><font color=3D"#666600">;</font></span><span style=3D"color: rgb(0,=
0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0</=
span></span><font color=3D"#38761d"><span style=3D"" class=3D"styled-by-pre=
ttify">"</span><span class=3D"pun" style=3D"font-family: inherit; font=
-style: inherit; font-variant: inherit; font-weight: inherit; white-space: =
inherit; background-color: rgb(239, 240, 241); font-size: inherit; font-str=
etch: inherit; line-height: inherit; vertical-align: baseline;">[</span><sp=
an class=3D"pln" style=3D"font-family: inherit; font-style: inherit; font-v=
ariant: inherit; font-weight: inherit; white-space: inherit; background-col=
or: rgb(239, 240, 241); font-size: inherit; font-stretch: inherit; line-hei=
ght: inherit; vertical-align: baseline;">_a</span><span class=3D"pun" style=
=3D"font-family: inherit; font-style: inherit; font-variant: inherit; font-=
weight: inherit; white-space: inherit; background-color: rgb(239, 240, 241)=
; font-size: inherit; font-stretch: inherit; line-height: inherit; vertical=
-align: baseline;">-</span><span class=3D"pln" style=3D"font-family: inheri=
t; font-style: inherit; font-variant: inherit; font-weight: inherit; white-=
space: inherit; background-color: rgb(239, 240, 241); font-size: inherit; f=
ont-stretch: inherit; line-height: inherit; vertical-align: baseline;">zA</=
span><span class=3D"pun" style=3D"font-family: inherit; font-style: inherit=
; font-variant: inherit; font-weight: inherit; white-space: inherit; backgr=
ound-color: rgb(239, 240, 241); font-size: inherit; font-stretch: inherit; =
line-height: inherit; vertical-align: baseline;">-</span><span class=3D"pln=
" style=3D"font-family: inherit; font-style: inherit; font-variant: inherit=
; font-weight: inherit; white-space: inherit; background-color: rgb(239, 24=
0, 241); font-size: inherit; font-stretch: inherit; line-height: inherit; v=
ertical-align: baseline;">Z</span><span class=3D"pun" style=3D"font-family:=
inherit; font-style: inherit; font-variant: inherit; font-weight: inherit;=
white-space: inherit; background-color: rgb(239, 240, 241); font-size: inh=
erit; font-stretch: inherit; line-height: inherit; vertical-align: baseline=
;">][</span><span class=3D"pln" style=3D"font-family: inherit; font-style: =
inherit; font-variant: inherit; font-weight: inherit; white-space: inherit;=
background-color: rgb(239, 240, 241); font-size: inherit; font-stretch: in=
herit; line-height: inherit; vertical-align: baseline;">_a</span><span clas=
s=3D"pun" style=3D"font-family: inherit; font-style: inherit; font-variant:=
inherit; font-weight: inherit; white-space: inherit; background-color: rgb=
(239, 240, 241); font-size: inherit; font-stretch: inherit; line-height: in=
herit; vertical-align: baseline;">-</span><span class=3D"pln" style=3D"font=
-family: inherit; font-style: inherit; font-variant: inherit; font-weight: =
inherit; white-space: inherit; background-color: rgb(239, 240, 241); font-s=
ize: inherit; font-stretch: inherit; line-height: inherit; vertical-align: =
baseline;">zA</span><span class=3D"pun" style=3D"font-family: inherit; font=
-style: inherit; font-variant: inherit; font-weight: inherit; white-space: =
inherit; background-color: rgb(239, 240, 241); font-size: inherit; font-str=
etch: inherit; line-height: inherit; vertical-align: baseline;">-</span><sp=
an class=3D"pln" style=3D"font-family: inherit; font-style: inherit; font-v=
ariant: inherit; font-weight: inherit; white-space: inherit; background-col=
or: rgb(239, 240, 241); font-size: inherit; font-stretch: inherit; line-hei=
ght: inherit; vertical-align: baseline;">Z0</span><span class=3D"pun" style=
=3D"font-family: inherit; font-style: inherit; font-variant: inherit; font-=
weight: inherit; white-space: inherit; background-color: rgb(239, 240, 241)=
; font-size: inherit; font-stretch: inherit; line-height: inherit; vertical=
-align: baseline;">-</span><span class=3D"lit" style=3D"font-family: inheri=
t; font-style: inherit; font-variant: inherit; font-weight: inherit; white-=
space: inherit; background-color: rgb(239, 240, 241); font-size: inherit; f=
ont-stretch: inherit; line-height: inherit; vertical-align: baseline;">9</s=
pan><span class=3D"pun" style=3D"font-family: inherit; font-style: inherit;=
font-variant: inherit; font-weight: inherit; white-space: inherit; backgro=
und-color: rgb(239, 240, 241); font-size: inherit; font-stretch: inherit; l=
ine-height: inherit; vertical-align: baseline;">]{</span><span class=3D"lit=
" style=3D"font-family: inherit; font-style: inherit; font-variant: inherit=
; font-weight: inherit; white-space: inherit; background-color: rgb(239, 24=
0, 241); font-size: inherit; font-stretch: inherit; line-height: inherit; v=
ertical-align: baseline;">0</span><span class=3D"pun" style=3D"font-family:=
inherit; font-style: inherit; font-variant: inherit; font-weight: inherit;=
white-space: inherit; background-color: rgb(239, 240, 241); font-size: inh=
erit; font-stretch: inherit; line-height: inherit; vertical-align: baseline=
;">,</span><span class=3D"lit" style=3D"font-family: inherit; font-style: i=
nherit; font-variant: inherit; font-weight: inherit; white-space: inherit; =
background-color: rgb(239, 240, 241); font-size: inherit; font-stretch: inh=
erit; line-height: inherit; vertical-align: baseline;">30</span><span class=
=3D"pun" style=3D"font-family: inherit; font-style: inherit; font-variant: =
inherit; font-weight: inherit; white-space: inherit; background-color: rgb(=
239, 240, 241); font-size: inherit; font-stretch: inherit; line-height: inh=
erit; vertical-align: baseline;">}</span><span style=3D"font-family: Arial,=
Helvetica, sans-serif;"><span class=3D"styled-by-prettify" style=3D"">&quo=
t;</span></span></font><span style=3D"font-family: Arial, Helvetica, sans-s=
erif; color: rgb(0, 0, 0);"><span class=3D"styled-by-prettify">regex=C2=A0<=
/span></span><span style=3D"font-family: Arial, Helvetica, sans-serif; colo=
r: rgb(102, 102, 0);"><span class=3D"styled-by-prettify">:</span></span><sp=
an style=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);=
"><span class=3D"styled-by-prettify"> </span></span><span style=3D"font-fam=
ily: Arial, Helvetica, sans-serif; color: rgb(136, 0, 0);"><span class=3D"s=
tyled-by-prettify">// ranges and regular expressions, nice !</span></span><=
br><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">=C2=A0=
=C2=A0=C2=A0</span><span class=3D"styled-by-prettify"><font color=3D"#0000=
88">// Code<br></font></span><span style=3D"color: rgb(0, 0, 136);"><span c=
lass=3D"styled-by-prettify">case</span></span><span class=3D"styled-by-pret=
tify" style=3D""><font color=3D"#000000">=C2=A0YES</font><font color=3D"#66=
6600">;</font></span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 0);">=C2=A0</span><span class=3D"styled-by-prettify"><font color=3D"=
#006666">10r.100r</font><font color=3D"#666600">;</font></span><span style=
=3D"color: rgb(0, 0, 0);"><span class=3D"styled-by-prettify">=C2=A0</span><=
/span><span style=3D"color: rgb(0, 136, 0);"><span class=3D"styled-by-prett=
ify">"AA"</span></span><span style=3D"color: rgb(0, 0, 0);"><span=
class=3D"styled-by-prettify">r</span></span><span style=3D"color: rgb(102,=
102, 0);"><span class=3D"styled-by-prettify">.</span></span><span style=3D=
"color: rgb(0, 136, 0);"><span class=3D"styled-by-prettify">"AX"<=
/span></span><span style=3D"color: rgb(0, 0, 0);"><span class=3D"styled-by-=
prettify">r=C2=A0</span></span><span style=3D"color: rgb(102, 102, 0);"><sp=
an class=3D"styled-by-prettify">:</span></span><span style=3D"color: rgb(0,=
0, 0);"><span class=3D"styled-by-prettify">=C2=A0</span></span><span style=
=3D"color: rgb(136, 0, 0);"><span class=3D"styled-by-prettify">// ranges ca=
n be of std::strings too ( or const char* ),</span></span><span style=3D"co=
lor: rgb(136, 0, 0);"><span class=3D"styled-by-prettify">=C2=A0why not ?</s=
pan></span><span style=3D"color: rgb(0, 0, 0);"><span class=3D"styled-by-pr=
ettify"><br></span></span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(0, 0, 0);">=C2=A0 =C2=A0=C2=A0</span><span class=3D"styled-by-prettif=
y"><font color=3D"#000088">// Code<br></font></span><span style=3D"color: r=
gb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
ase</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span></span><span style=3D"color: r=
gb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-prettify">d=
efault</span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D=
"color: #660;" class=3D"styled-by-prettify">:</span></span><span style=3D"c=
olor: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> <br></span></span><span style=3D"color: rgb(102, 102, 0);"><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v><div><br></div>I think this covers almost all problems:</div><div>1 - Can=
be used with std::string ( or anything else: std::variant, std::string_vie=
w, std::vector =C2=A0)=C2=A0</div><div>2 - Can be used with ranges ( analog=
ous to ".." operator ). I wonder... can I use two unary postfix &=
quot;dot" operator in a sequence ?</div><div>3 - Can be used with many=
arguments at once.</div><div>4 - Execute functions, make temporaries and d=
eclare variables at the beginning</div><div>5 - Avoid unintentional fallthr=
ough</div><div>6 - Leave the old switch alone</div><div><br></div><div>But =
still get the problem :=C2=A0</div><div><br></div><div>switch megazord (&qu=
ot;A") { // this is a const char * pointer and one cannot overload =
9;'=3D=3D"</div><div>}</div><div><br></div><div>We need</div><div>=
<br></div><div>switch megazord("A"s) { =C2=A0// <- string lite=
ral=C2=A0<br></div><div>}</div><div><br></div><div><br></div><div><br>P.S. =
I know... I know... megazord is not a good name, may be 'batman' in=
stead</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/cb29f028-f791-4cb7-8593-5683995839f3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cb29f028-f791-4cb7-8593-5683995839f3=
%40isocpp.org</a>.<br />
------=_Part_291_1921638203.1502321351132--
------=_Part_290_1863104350.1502321351131--
.
Author: gmisocpp@gmail.com
Date: Wed, 9 Aug 2017 18:13:12 -0700 (PDT)
Raw View
------=_Part_365_1320432237.1502327592752
Content-Type: multipart/alternative;
boundary="----=_Part_366_1083946621.1502327592752"
------=_Part_366_1083946621.1502327592752
Content-Type: text/plain; charset="UTF-8"
On Thursday, August 10, 2017 at 5:08:18 AM UTC+12, Tony V E wrote:
>
> break by default is fine, how do I opt-out within switch break, or is it
> all or nothing?
>
> switch break(x)
> {
> case 1:
> case 2:
> foo();
> case 3:
> bar();
> case 4:
> etc();
> }
>
>
> How do I get fallthru on case 1 to 2?
>
I would not object to fallthrough being a keyword like so (but see later):
switch break(x)
{
case 1: fallthrough;
case 2:
foo();
case 3:
bar();
case 4:
etc();
}
But I might prefer - in the absence of some range of values syntax - to
make an empty case automatically fallthrough;
and if you don't want to fall through use an empty statement as shown
below, because the need is common and it's much briefer.
switch break(x)
{
case 1: ; // Don't fall through.
case 2:
foo();
case 3:
bar();
case 4:
etc();
}
And if you want to fallthrough in the middle of some case, just use goto.
Which I think is clearer.
And if you are using fallthrough that often, just use switch not switch
break.
What do you think?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/bffc4188-593d-426e-bf4c-01c6a2952087%40isocpp.org.
------=_Part_366_1083946621.1502327592752
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, August 10, 2017 at 5:08:18 AM UTC+12,=
Tony V E wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px =
0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border=
-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div><div><di=
v><div><div><div><div><div><div><div><div><div><div><div><div>break by defa=
ult is fine, how do I opt-out within switch break, or is it all or nothing?=
<br><br></div>switch break(x)<br>{<br></div>case 1:<br></div>case 2:<br></d=
iv>=C2=A0=C2=A0=C2=A0 foo();<br></div>case 3:<br></div>=C2=A0=C2=A0=C2=A0 b=
ar();<br></div>case 4:<br></div>=C2=A0=C2=A0=C2=A0 etc();<br>=C2=A0}<br><br=
><br></div>How do I get fallthru on case 1 to 2?<br></div></div></div></div=
></div></div></div></blockquote><div><br></div><div>I would not object to f=
allthrough being a keyword like so (but see later):</div><div><br></div><di=
v>switch break(x)<br>{<br>case 1: fallthrough;<br>case 2:<br>=C2=A0=C2=A0=
=C2=A0 foo();<br>case 3:<br>=C2=A0=C2=A0=C2=A0 bar();<br>case 4:<br>=C2=A0=
=C2=A0=C2=A0 etc();<br>=C2=A0}<br></div><div><br></div><div>But I might pre=
fer - in the absence of some range of values syntax -=C2=A0to make an=C2=A0=
empty case automatically fallthrough;</div><div>and if you don't want t=
o fall through use an empty statement as shown below, because the need is c=
ommon and it's much briefer.</div><div><br></div><div>switch break(x)<b=
r>{<br>case 1: ; // Don't fall through.<br>case 2:<br>=C2=A0=C2=A0=C2=
=A0 foo();<br>case 3:<br>=C2=A0=C2=A0=C2=A0 bar();<br>case 4:<br>=C2=A0=C2=
=A0=C2=A0 etc();<br>=C2=A0}<br></div><div><div>And if you want to fallthrou=
gh in the middle of some case, just use goto. Which I think is clearer.</di=
v><div>And if you are using fallthrough that often, just use switch not swi=
tch break.</div><div><br></div><div>What do you think?<br></div></div><div>=
<br></div>
</div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/bffc4188-593d-426e-bf4c-01c6a2952087%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bffc4188-593d-426e-bf4c-01c6a2952087=
%40isocpp.org</a>.<br />
------=_Part_366_1083946621.1502327592752--
------=_Part_365_1320432237.1502327592752--
.
Author: Bo Persson <bop@gmb.dk>
Date: Thu, 10 Aug 2017 04:23:10 +0200
Raw View
On 2017-08-10 03:13, gmisocpp@gmail.com wrote:
>
>
> On Thursday, August 10, 2017 at 5:08:18 AM UTC+12, Tony V E wrote:
>
> break by default is fine, how do I opt-out within switch break, or
> is it all or nothing?
>
> switch break(x)
> {
> case 1:
> case 2:
> foo();
> case 3:
> bar();
> case 4:
> etc();
> }
>
>
> How do I get fallthru on case 1 to 2?
>
>
> I would not object to fallthrough being a keyword like so (but see later):
>
> switch break(x)
> {
> case 1: fallthrough;
> case 2:
> foo();
> case 3:
> bar();
> case 4:
> etc();
> }
>
That would make it really experts-only, as we already have the current
version
switch (x)
{
case 1: [[fallthrough]];
case 2:
foo();
case 3:
bar();
case 4:
etc();
}
How many variations do we need?
Bo Persson
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/omgg26%24pob%241%40blaine.gmane.org.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 9 Aug 2017 22:45:24 -0400
Raw View
--001a113d3aac4008d805565d3086
Content-Type: text/plain; charset="UTF-8"
On Wed, Aug 9, 2017 at 10:23 PM, Bo Persson <bop@gmb.dk> wrote:
> On 2017-08-10 03:13, gmisocpp@gmail.com wrote:
>
>>
>>
>> On Thursday, August 10, 2017 at 5:08:18 AM UTC+12, Tony V E wrote:
>>
>> break by default is fine, how do I opt-out within switch break, or
>> is it all or nothing?
>>
>> switch break(x)
>> {
>> case 1:
>> case 2:
>> foo();
>> case 3:
>> bar();
>> case 4:
>> etc();
>> }
>>
>>
>> How do I get fallthru on case 1 to 2?
>>
>>
>> I would not object to fallthrough being a keyword like so (but see later):
>>
>> switch break(x)
>> {
>> case 1: fallthrough;
>> case 2:
>> foo();
>> case 3:
>> bar();
>> case 4:
>> etc();
>> }
>>
>>
> That would make it really experts-only, as we already have the current
> version
>
> switch (x)
> {
> case 1: [[fallthrough]];
> case 2:
> foo();
> case 3:
> bar();
> case 4:
> etc();
> }
>
>
> How many variations do we need?
>
>
> Bo Persson
>
>
Well, the [[fallthrough]] one, in some sense, doesn't really exist, because
attributes are ignorable and don't change anything.
I don't expect to ever get "switch break (x)", but I do expect we
eventually get pattern matching that subsumes switch. Maybe "switch [x]",
since square brackets are in style? Or throw in an auto or something. Or
it is called "inspect" (that's the name Bjarne used).
When we do get "inspect", it we almost certainly break by default. I think
we will still _probably_ need something to do fallthrough - and it can't be
an attribute.
Or maybe we say fallthrough really isn't worth it.
--
Be seeing you,
Tony
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbisUO1-rHoSrFK-qc76OFxPsVx3NJOnyV6vb1WFDcwQ-NA%40mail.gmail.com.
--001a113d3aac4008d805565d3086
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, Aug 9, 2017 at 10:23 PM, Bo Persson <span dir=3D"ltr"><<a hr=
ef=3D"mailto:bop@gmb.dk" target=3D"_blank">bop@gmb.dk</a>></span> wrote:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><span>On 2017-08-10 03:13, <a href=3D"ma=
ilto:gmisocpp@gmail.com" target=3D"_blank">gmisocpp@gmail.com</a> wrote:<br=
>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
<br>
<br>
On Thursday, August 10, 2017 at 5:08:18 AM UTC+12, Tony V E wrote:<br>
<br>
=C2=A0 =C2=A0 break by default is fine, how do I opt-out within switch brea=
k, or<br>
=C2=A0 =C2=A0 is it all or nothing?<br>
<br>
=C2=A0 =C2=A0 switch break(x)<br>
=C2=A0 =C2=A0 {<br>
=C2=A0 =C2=A0 case 1:<br>
=C2=A0 =C2=A0 case 2:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0foo();<br>
=C2=A0 =C2=A0 case 3:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bar();<br>
=C2=A0 =C2=A0 case 4:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0etc();<br>
=C2=A0 =C2=A0 =C2=A0 }<br>
<br>
<br>
=C2=A0 =C2=A0 How do I get fallthru on case 1 to 2?<br>
<br>
<br>
I would not object to fallthrough being a keyword like so (but see later):<=
br>
<br>
switch break(x)<br>
{<br>
case 1: fallthrough;<br>
case 2:<br>
=C2=A0 =C2=A0 =C2=A0foo();<br>
case 3:<br>
=C2=A0 =C2=A0 =C2=A0bar();<br>
case 4:<br>
=C2=A0 =C2=A0 =C2=A0etc();<br>
=C2=A0 }<br>
<br>
</blockquote>
<br></span>
That would make it really experts-only, as we already have the current vers=
ion<br>
<br>
switch (x)<span><br>
{<br>
case 1: [[fallthrough]];<br>
case 2:<br>
=C2=A0 =C2=A0 =C2=A0foo();<br>
case 3:<br>
=C2=A0 =C2=A0 =C2=A0bar();<br>
case 4:<br>
=C2=A0 =C2=A0 =C2=A0etc();<br>
=C2=A0 }<br>
<br>
<br></span>
How many variations do we need?<br>
<br>
<br>
=C2=A0 =C2=A0 Bo Persson<span><br>
<br></span></blockquote><div><br></div><div>Well, the [[fallthrough]] one, =
in some sense, doesn't really exist, because attributes are ignorable a=
nd don't change anything.<br><br></div><div>I don't expect to ever =
get "switch break (x)", but I do expect we eventually get pattern=
matching that subsumes switch.=C2=A0 Maybe "switch [x]", since s=
quare brackets are in style? Or throw in an auto or something.=C2=A0 Or it =
is called "inspect" (that's the name Bjarne used).<br><br></d=
iv><div>When we do get "inspect", it we almost certainly break by=
default.=C2=A0 I think we will still _probably_ need something to do fallt=
hrough - and it can't be an attribute.<br></div><div>Or maybe we say fa=
llthrough really isn't worth it.<br><br><br></div></div>-- <br><div cla=
ss=3D"m_736059209292639619gmail_signature" data-smartmail=3D"gmail_signatur=
e"><div dir=3D"ltr"><div>Be seeing you,<br></div>Tony<br></div></div>
</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbisUO1-rHoSrFK-qc76OFxPsVx3NJOny=
V6vb1WFDcwQ-NA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbisUO1-rHoSr=
FK-qc76OFxPsVx3NJOnyV6vb1WFDcwQ-NA%40mail.gmail.com</a>.<br />
--001a113d3aac4008d805565d3086--
.