220 33764 <bffc4188-593d-426e-bf4c-01c6a2952087@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: gmisocpp@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: A more advanced switch
Date: Wed, 9 Aug 2017 18:13:12 -0700 (PDT)
Lines: 123
Approved: news@gmane.org
Message-ID: <bffc4188-593d-426e-bf4c-01c6a2952087@isocpp.org>
References: <f8c908e2-d06f-4cd1-bda0-fe2b97fd21f1@isocpp.org> <574320af-c1ae-4676-883c-ae4e91fcd874@isocpp.org>
 <CAOHCbisLgTxLz75Em3Had35AecQrtpRZKFWRaMXUZsSVtN7Fng@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_365_1320432237.1502327592752"
X-Trace: blaine.gmane.org 1502327598 16398 195.159.176.226 (10 Aug 2017 01:13:18 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 10 Aug 2017 01:13:18 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCM3TRNUXUDBBKPGV3GAKGQEPJ7E6BQ@isocpp.org Thu Aug 10 03:13:13 2017
Return-path: <std-proposals+bncBCM3TRNUXUDBBKPGV3GAKGQEPJ7E6BQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f72.google.com ([74.125.83.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCM3TRNUXUDBBKPGV3GAKGQEPJ7E6BQ@isocpp.org>)
	id 1dfc28-0003mP-Ov
	for gclcip-std-proposals@m.gmane.org; Thu, 10 Aug 2017 03:13:08 +0200
Original-Received: by mail-pg0-f72.google.com with SMTP id t80sf82349829pgb.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Aug 2017 18:13:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=Op7XgquKR2AyGwRZwNEI2AEbZfGbZddUPVShiZoszpA=;
        b=bggMUdxyH7r7UdvpBqmiIULrbHDJ6k+UwHR/RA2l07S+TQxUhLRF7k0fZJ2msqQBsQ
         mrBZy152HYRgvG9RSIy1a/eC3ppuJ/XsvZyjy776k5ZnvGOzFr2BxAeczH/LWn4sd/eT
         9ngJWxArA+8fMxjME/aHA6K6U9bM+i7+7CLb058duM6rPPy3qmMddj90ueWLzd7gUUNT
         MfZOYVfVSBVJpC+RyZ8XVz/7IPU+XtEIOnAtXqNxLQ9eQ/gg2ipZxg8w1ommFHr1JM0k
         3AranolDJD3e4h5l26RgVKxtRIMPhIrYraBriXDJAKxV42E8d9IZSIt/ms//IJ7AqQOB
         yBmA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=Op7XgquKR2AyGwRZwNEI2AEbZfGbZddUPVShiZoszpA=;
        b=EiyuCtO+p+5xSHWRSMHxNJKcHOPvPZa7+nT2OfM1ejPx3o5hdCbn3Jo8SN8DGcMBLN
         9b6iFjeyHJZfz72383S/HflUrDdLuX+Wu6DCBAnCUdxBsaDubsvBrU3uk5ATUvxDlC5v
         wvThI5QIPyFdVdK3Cu7dfsPXbA0XL3SDuZCK9tWKSq6J6P3F3HynTHP3Ai4KQJLhQA/g
         /EhUAnlryZSMtrMCIko9oQ1+mOJTvA5IQQxnQKlB4SZvctpI0ISfB6MhXZvnFCiLi293
         ue7vwvy4cdnLS8Pg/JG9FmypLkzHlsnwjl5v6hgT5Pa70bjRn65i1g3P9ZSSC/VfBCZT
         k09Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=Op7XgquKR2AyGwRZwNEI2AEbZfGbZddUPVShiZoszpA=;
        b=VFR7O5nya/TqmD6lrbB4OwE1vaDSk9XV0zvN3Ty9MvW0n0aL8xWOEZH5oy60syI8qR
         F4AfLpwJWEBac/JdqdzUBKrEZ9wAhXP4sBiu22ta2m1cPfStHYDFIw4c6/8nXaUxFmpT
         JF8MlY1sxKe5bShKIXBLdi3iDojhx2zESygrDVWZHl8EhT8XqHCaGIZpVxEhmWd3hf4q
         hp2vBQgEHFcys9e+7XRA/2VUCxqeOqTQRslMaQywZzkFHqCMTpV6BlD+mWbS3gvogYtf
         rbPjNuhGF8ISTXIpDI7vvPIhevHsJHo81GCb8SIcWn4BcBHIQkKvqtF+p0WKLrl8gsLQ
         wJ0g==
X-Gm-Message-State: AHYfb5jLD6XuR8HoQZzagAhs+UCjgBTdEUOa1PMmLIGEKf8DxnThuJ6x
	1BeOp4YE3YcGWe4Z
X-Received: by 10.99.122.79 with SMTP id j15mr6633180pgn.55.1502327594497;
        Wed, 09 Aug 2017 18:13:14 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.69.222 with SMTP id c91ls10474843itd.0.canary-gmail; Wed,
 09 Aug 2017 18:13:13 -0700 (PDT)
X-Received: by 10.31.41.67 with SMTP id p64mr43103vkp.16.1502327593208;
        Wed, 09 Aug 2017 18:13:13 -0700 (PDT)
In-Reply-To: <CAOHCbisLgTxLz75Em3Had35AecQrtpRZKFWRaMXUZsSVtN7Fng@mail.gmail.com>
X-Original-Sender: gmisocpp@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:33764
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33764>

------=_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&#39;t want t=
o fall through use an empty statement as shown below, because the need is c=
ommon and it&#39;s much briefer.</div><div><br></div><div>switch break(x)<b=
r>{<br>case 1: ; // Don&#39;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&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/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--

.
