220 33730 <CAOHCbisLgTxLz75Em3Had35AecQrtpRZKFWRaMXUZsSVtN7Fng@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Tony V E <tvaneerd@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: A more advanced switch
Date: Wed, 9 Aug 2017 13:08:14 -0400
Lines: 391
Approved: news@gmane.org
Message-ID: <CAOHCbisLgTxLz75Em3Had35AecQrtpRZKFWRaMXUZsSVtN7Fng@mail.gmail.com>
References: <f8c908e2-d06f-4cd1-bda0-fe2b97fd21f1@isocpp.org> <574320af-c1ae-4676-883c-ae4e91fcd874@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a114a826c1ec62b0556552041"
X-Trace: blaine.gmane.org 1502298499 18862 195.159.176.226 (9 Aug 2017 17:08:19 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 9 Aug 2017 17:08:19 +0000 (UTC)
To: Standard Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCUZ5QWKNQIP7AVNZQCRUBHSIU7GW@isocpp.org Wed Aug 09 19:08:13 2017
Return-path: <std-proposals+bncBCUZ5QWKNQIP7AVNZQCRUBHSIU7GW@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f200.google.com ([209.85.192.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUZ5QWKNQIP7AVNZQCRUBHSIU7GW@isocpp.org>)
	id 1dfUSp-0004Wd-S6
	for gclcip-std-proposals@m.gmane.org; Wed, 09 Aug 2017 19:08:12 +0200
Original-Received: by mail-pf0-f200.google.com with SMTP id r13sf67982044pfd.14
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Aug 2017 10:08:18 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1502298497; cv=pass;
        d=google.com; s=arc-20160816;
        b=NXKpfO5+1a+qDIidH+0U526mSwhqck+6p/2T2fPnhxrqPY7FHTNBJyz/pJFKjC72B/
         ED2uS/eGa3rFeujeSnXKfnUF4sNSa6ylxW923NROyfrGK3/IrAK1W4vZeUcp/hmxs8zF
         jPizzwTg4mxQv91fIn8IKwI46Uo25ZQzqJu02PxAOOJDLRzNxQnVOHOZAx+2IbLiwcHy
         /0rl/xnxkixZb80GdPIJ3JV/CE4keaLSzCHrFbeuGqMVQJuwTZ8QJbXVY1SZlfZ3JIKV
         pua+3dvc6MKTLPBrHrNVA5gTvURO8mk3o4HdFBSXhk3FjwBmlbfVEtQ3K4yZANPx2D4+
         Rq7g==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=W5X//ncwEhMjWPRBwXXf6R3q0Z/TDAAH/Fd+W3mE5jg=;
        b=OkqxQShaKivti7Z4+ykWv9ZGzBLP4Su5ZQZmWX2V9sTMHYUqZ5OffDLeDKbW+t/fzf
         oCl5CJRAwKUGKiTD7rsNGBbvxZlAXKA4By7Ksg6Ld//3stVI2/Kohf+gYGPH5FK+pETS
         DrjAm3jO2DaiQdCl2grFOxaXsjqKzZwbEfLu2rQj9Xm0MNYsHjLVLflyEUf81BTEs9ig
         lB+liTnS8uVT0j02us84pQp4ZrjjIIVTGJ7onfCWdfar9LikEUvTdSpTVadMnuf7N/50
         4lC6iYxsw6rzLseX4j+kS0JtKL8CKHfh4QsRUNS9wvo1Mk6SryeWdoHq26Ix1B/k5j++
         l5vw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=GX9EqREK;
       spf=pass (google.com: domain of tvaneerd@gmail.com designates 2607:f8b0:400d:c09::235 as permitted sender) smtp.mailfrom=tvaneerd@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=W5X//ncwEhMjWPRBwXXf6R3q0Z/TDAAH/Fd+W3mE5jg=;
        b=pi0mST4mZUNvDb5fgZwdWVMVMOX5rpr09zcu+UV+8go1xnD0k0iDd1yvBH/OmwJxCS
         EidEED2KSlliNTNwRsJ6RFaTQDPm+x8LlujpADLcdc+NjUE2KknpSXjpxLRykMKQTd86
         VRPk4Ah1Dn7rYE+hSrM/NypVLEtGoJpYtbimQzylA4oDuHOFCLVE8WtGsGaRzNKQoRP1
         6GuqOen7KJ7Krmf7qThcTWz6YCodifr7WwKShgeqtqERgrhk6hHGuIeq1aQ5C0PrSDnT
         xJoxQXAyFSk/+kxkElspgz/vkHXHGoudn+FWgPEc0CDTlXVKY4GZ+/u+OItXyRFe9lz6
         03zw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=W5X//ncwEhMjWPRBwXXf6R3q0Z/TDAAH/Fd+W3mE5jg=;
        b=TlkG1AUBJXfs0T6QijakRif76obrTc9gqfgq7I05En3Wk99N/PYGnu5L1Dc+rRWWFJ
         u8U58yunpiP10l5svGWmYaI9n0R+hKDLGQNCqBiOrEwVYhlkv1ukib5r62ezSqNo8vwD
         thtiIOVWKC0eUfxIS3Q0UBREHGwzeaxGgFLjInQhVwa0v7qmc4Ehs2EH1IF8gEzBwKK/
         BEdlQqAcX02Bardlv3FTVt4SfSoCZg0LN6T/ChenTCF8rtFl+LlbNvlzl0gIyFu6hEha
         scTFnoS1Yd5cvu0lpmQNPdBprJ9KN3lMlvqDeCRoLyIy8YnOAzf174yqg7wbjEi83HXT
         0KFw==
X-Gm-Message-State: AHYfb5jy3mCBdoVrXuY7tQnxlKLT0wc/EyFgGsv2peszsInxR5YrFxSW
	WiwOYEiQUkOzjkMH
X-Received: by 10.99.0.19 with SMTP id 19mr5648364pga.48.1502298497534;
        Wed, 09 Aug 2017 10:08:17 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.192.65 with SMTP id u62ls5682482itf.2.gmail; Wed, 09 Aug
 2017 10:08:15 -0700 (PDT)
X-Received: by 10.237.36.155 with SMTP id t27mr11053158qtc.314.1502298495052;
        Wed, 09 Aug 2017 10:08:15 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1502298495; cv=none;
        d=google.com; s=arc-20160816;
        b=iMOFt7hwxOFIZeOceKNgucjj/tr9taZz63EG394AM6ZpQ1CvUmRDlecUEo1jepSdJn
         FtctRg5xDVGBwYN1RJfAJj4I7TJmGzESO/e1achuHRQs1HmytfIr3zGtUYxWnXvXHr4/
         XaFgxfIOhUCqCKLFgeiI3j1f7FMDrywA4l2SQwljGc/x9CnGP69L63LLYa60lRYXWGxC
         n5mMqZhloTzVTMVdtnt7J6vkwowDE5g4MInutDpoKGjrh1d9PkaIWcdgITgjww9E59i5
         LPVnaX7wSbtMh0/PmJz+uwex0Rb7ewBV7hxuYBuQYd1Wpj9kTo/5WTavCA98BegLX2YE
         tNKw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=ReBid/ESmIHms7BB8iefgAnK7WLDmLJ1TlKrJ2H2pR4=;
        b=E73P0SOxPxVWASfmM3rVf0qnmLcz5RoWNi+CZywqQnfLfnTWjgCkgTXiR8+W05ZZkC
         M7gEz/nnzE5MrHIzEBFXXyIyFx5Xcat8A9XPx2IA4Di238ur5EfsB4xKlRgTdNltN5aY
         FIgo87MebS3x8qy0WwvdrzL47WLfK8xLJW/dnclbrF0YjzSnLVlg4nfZ+9phmpCUDFHd
         XObfe3UHUCWYpknlFoDna3sR8dcyrHlHQqZvaK2cSMsEml4GEKIcjrO5disKj5yClD3C
         9xUUPB6G4LHhRsABuTJ3OpTjg/e/aFYpqjBbcTJkn/neMxMXkJO7XDFCsVWEaIeDIOF5
         xOXg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=GX9EqREK;
       spf=pass (google.com: domain of tvaneerd@gmail.com designates 2607:f8b0:400d:c09::235 as permitted sender) smtp.mailfrom=tvaneerd@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-qk0-x235.google.com (mail-qk0-x235.google.com. [2607:f8b0:400d:c09::235])
        by mx.google.com with ESMTPS id s57si3352569qtc.220.2017.08.09.10.08.15
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 09 Aug 2017 10:08:15 -0700 (PDT)
Received-SPF: pass (google.com: domain of tvaneerd@gmail.com designates 2607:f8b0:400d:c09::235 as permitted sender) client-ip=2607:f8b0:400d:c09::235;
Original-Received: by mail-qk0-x235.google.com with SMTP id d145so39737734qkc.2
        for <std-proposals@isocpp.org>; Wed, 09 Aug 2017 10:08:15 -0700 (PDT)
X-Received: by 10.55.74.142 with SMTP id x136mr10432836qka.254.1502298494648;
 Wed, 09 Aug 2017 10:08:14 -0700 (PDT)
Original-Received: by 10.237.42.10 with HTTP; Wed, 9 Aug 2017 10:08:14 -0700 (PDT)
In-Reply-To: <574320af-c1ae-4676-883c-ae4e91fcd874@isocpp.org>
X-Original-Sender: tvaneerd@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=GX9EqREK;       spf=pass
 (google.com: domain of tvaneerd@gmail.com designates 2607:f8b0:400d:c09::235
 as permitted sender) smtp.mailfrom=tvaneerd@gmail.com;       dmarc=pass
 (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:33730
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33730>

--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">&gt;<br>
&gt; switch (s)<br>
&gt; {<br>
&gt; case &quot;A&quot;:<br>
&gt; case &quot;B&quot;:<br>
&gt; default:<br>
&gt; }<br>
&gt;<br><br></span></div><span class=3D"gmail-im">I&#39;ve seen C code do t=
his, where s was a char *. (And s was typically pointing to static chars, l=
ike s =3D &quot;B&quot;)<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&#39;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">&lt;<a href=3D"mailto:gmisocpp@gmail.com" target=3D=
"_blank">gmisocpp@gmail.com</a>&gt;</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&#39;=
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&#39;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&#39;t required.</div><div>So this switch could be used when it&#39;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&#39;m sorry i=
f you talked about this here before, but I didn&#39;t watch this group and =
I couldn&#39;t find this thing when searching.<div><br></div><div>I&#39;m c=
oming from another language named Pawn, it looks like C ~80%, but it has mo=
re advantages than C. Here&#39;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++: &quot;switch&quot; 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 &quot;if&quot; ... &quot;else if&quot; ... &quot;else&quot; =
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 &quot;default&quot; 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&quot; for every, well, case when specifying a sequence, because it =
uses fallthrough. We have to use &quot;break&quot; to avoid that. I find th=
is bad. Because of the necessity of using &quot;break&quot; we can&#39;t ju=
st &quot;break&quot; 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 &quot;switch&quot; isn&#39;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&#39;s no ne=
ed for break, there&#39;s no fallthrough. Advantage: we can easily &quot;co=
ntinue&quot; and &quot;break&quot; loops from inside the &quot;switch&quot;=
..</div><div>2. We can use &quot;..&quot; 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&#39;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&#39;s [[fallthrough]] attribute is just as complicated as t=
he &quot;switch&quot;. 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&quot; 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&amp;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&quot; 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--

.
