220 33755 <cb29f028-f791-4cb7-8593-5683995839f3@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Cleiton Santoia <cleitonsantoia@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: A more advanced switch
Date: Wed, 9 Aug 2017 16:29:11 -0700 (PDT)
Lines: 351
Approved: news@gmane.org
Message-ID: <cb29f028-f791-4cb7-8593-5683995839f3@isocpp.org>
References: <f8c908e2-d06f-4cd1-bda0-fe2b97fd21f1@isocpp.org> <5a36b655-b2a9-4be2-8599-465810cfd1b3@isocpp.org>
 <CAFk2RUYqZVo775jwQP+AGiqf3JRq8yNxB1Ru_b74YPa-qJfooA@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_290_1863104350.1502321351131"
X-Trace: blaine.gmane.org 1502321355 27557 195.159.176.226 (9 Aug 2017 23:29:15 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 9 Aug 2017 23:29:15 +0000 (UTC)
Cc: costelnistor12@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCBMVWMTUUNBBR5VV3GAKGQE2OBWTLI@isocpp.org Thu Aug 10 01:29:10 2017
Return-path: <std-proposals+bncBCBMVWMTUUNBBR5VV3GAKGQE2OBWTLI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f72.google.com ([209.85.214.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCBMVWMTUUNBBR5VV3GAKGQE2OBWTLI@isocpp.org>)
	id 1dfaPS-0006gL-Q8
	for gclcip-std-proposals@m.gmane.org; Thu, 10 Aug 2017 01:29:07 +0200
Original-Received: by mail-it0-f72.google.com with SMTP id 77sf8971586itj.4
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Aug 2017 16:29:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc: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=dN8jpmo4Mua8Reob+cRuhpIhPekDuvyDKl+Yk6W4z1M=;
        b=JbDUKy7LdaICixVEgRTVeqQwfd2QYQu/legIE/nynQr5uvlPmVwcsaB6/Pwh78PRID
         p67Xn2ScuACFJeFn+jHHBV4cTHe5Pr4QSP3EIlOB/WdZHuIn5QMnphvnzW+UG9YitBLW
         qpfW2mjZLEloyHzkWUfvmM4AhLeugDutad2nk8lxLXAeebX5ySL18djZ51MLTub+mNem
         E/SGC+PPYGcZh2ntxaRgGRaUB3nBbp0pugR6cFYuZ/iFMnN5+ZYN3MYJe7YNCPwKvIAw
         upkeGYLXEOONEPuk/Eo3H/FMS6DV9VQHWMr8PGxHr+H7XCUnNsCDOF/ITq7uED0dxezx
         gxPg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:cc: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=dN8jpmo4Mua8Reob+cRuhpIhPekDuvyDKl+Yk6W4z1M=;
        b=eURpT9lLPsT01PHQLrDgrUbf/0wii9GRxgJiJDQiSteVHiR6qiV1W58d9lwpDW7Qr3
         t6dkYIHPcKvEtp5CzeN88OWahprN220RwOM7ExanUPnwYFLGy/bYo2KJjEg4Tqb53R3L
         3JTAApC6cyyBmQjvkUy87svq7bPZLVgLd5VRYfh1YSVlklemzdbyXJdfbT2tYG9a1xm/
         /EhuPqb7jrmnd9yhPb+UEEGsob89I4G80WKrpT43wNFr+FD1StcDzgf/48Dl2WaeeyTt
         6mizhA3ZnffElfJ204ckOJulJNu9RZoZroQ3dK5b+50+VfK0P+nyK3+mRBe6j1tr/cVP
         8ckg==
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:cc: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=dN8jpmo4Mua8Reob+cRuhpIhPekDuvyDKl+Yk6W4z1M=;
        b=kOqAI2Qy9Pdkfq72t+Cz8XSrvKqKxepC0a/w4Wjpa7xsO3UJlwfThrAgJ0SADuBTyf
         i4Rgpi9Y+YNcqQxy5/mJyFJNEsw5u0Qsk8lCSlyrJ6dZ3O1UnrpyKRNVxDRkv3/RvUpA
         E2CDRbNQeKdB57ONBEuKlkitSZmFSCnS++IU1m+F9I+SpBSmbDpHXz3U2LJLe4un4HW1
         5ddFdbDQsp34TTcC9PxnCAQST9j3YPIp7Wx6i/x+8JRhPj3IT6Oa2jo88sJjZgTDNHYl
         p18r5Jkf4CyvAfziqGqfeKLnLlwv+Po3kv4zjBI+0Zb/PO//a8HwYfinH85ejl9kSbye
         k/vw==
X-Gm-Message-State: AHYfb5h74al0pkEKkkGf0ihSU7riQsV3HYkxdP73FZWWSGuOjUNn9gao
	4WRa+IGrgCOyyVD/
X-Received: by 10.107.46.29 with SMTP id i29mr6180413ioo.55.1502321352792;
        Wed, 09 Aug 2017 16:29:12 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.178.88 with SMTP id b85ls11549496iof.5.gmail; Wed, 09 Aug
 2017 16:29:11 -0700 (PDT)
X-Received: by 10.31.157.209 with SMTP id g200mr52634vke.9.1502321351611;
        Wed, 09 Aug 2017 16:29:11 -0700 (PDT)
In-Reply-To: <CAFk2RUYqZVo775jwQP+AGiqf3JRq8yNxB1Ru_b74YPa-qJfooA@mail.gmail.com>
X-Original-Sender: cleitonsantoia@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:33755
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33755>

------=_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&#39;=
s not a switch, that&#39;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&#39;t fit into general matching, and other expectati=
ons
<br>that a general
<br>matching mechanism doesn&#39;t have, including recommendations against =
using switch
<br>because switch does fall-through and a general matching mechanism
<br>probably shouldn&#39;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 &quot;new&quot; switch, =
maybe via positional token ( megazord ), analogous to &quot;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 &quot;=3D=3D&quot; for eac=
h element and &quot;default break&quot; 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">&quot;AF-56&quot;</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">&quot;</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">&quot;AA&quot;</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">&quot;AX&quot;<=
/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 &quot;..&quot; operator ). I wonder... can I use two unary postfix &=
quot;dot&quot; 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&quot;) { // this is a const char * pointer and one cannot overload &#3=
9;&#39;=3D=3D&quot;</div><div>}</div><div><br></div><div>We need</div><div>=
<br></div><div>switch megazord(&quot;A&quot;s) { =C2=A0// &lt;- 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 &#39;batman&#39; 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&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/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--

.
