220 33742 <CAOHCbiv6n3oFG9Xj+QgPRhwdN2xDUV0zZvtYXXiALOXE3vOUhA@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 16:17:07 -0400
Lines: 118
Approved: news@gmane.org
Message-ID: <CAOHCbiv6n3oFG9Xj+QgPRhwdN2xDUV0zZvtYXXiALOXE3vOUhA@mail.gmail.com>
References: <f8c908e2-d06f-4cd1-bda0-fe2b97fd21f1@isocpp.org>
 <574320af-c1ae-4676-883c-ae4e91fcd874@isocpp.org> <CAOHCbisLgTxLz75Em3Had35AecQrtpRZKFWRaMXUZsSVtN7Fng@mail.gmail.com>
 <41733595.o4GQ0c89LU@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a1140c548a28efe055657c3b9"
X-Trace: blaine.gmane.org 1502309834 29824 195.159.176.226 (9 Aug 2017 20:17:14 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 9 Aug 2017 20:17:14 +0000 (UTC)
To: Standard Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCUZ5QWKNQIMJW5NZQCRUBHOWEQGG@isocpp.org Wed Aug 09 22:17:08 2017
Return-path: <std-proposals+bncBCUZ5QWKNQIMJW5NZQCRUBHOWEQGG@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f197.google.com ([209.85.220.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUZ5QWKNQIMJW5NZQCRUBHOWEQGG@isocpp.org>)
	id 1dfXPb-0007B5-JS
	for gclcip-std-proposals@m.gmane.org; Wed, 09 Aug 2017 22:17:03 +0200
Original-Received: by mail-qk0-f197.google.com with SMTP id x77sf34667335qka.15
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Aug 2017 13:17:10 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1502309829; cv=pass;
        d=google.com; s=arc-20160816;
        b=VMmuozWfX21VE9bdGknNHkp9+YpOObk+tdb7RPQjfIGqWUh+hxFMAm6ovpgkMeRWk9
         n0SxKWp4YVLSXgsTXyn5imNqSKVNk0x2rGF/FEvqWV6gJvhsm7eRKmtfwPkxYNNBxdSW
         jSjqIQJEPatNfa1TYDWZUve7Bdb/qWU/J0cYoX2c3Xle0rG1/NPBBG+MXEj9eq9u6WOs
         YuvjVSy/J87dQFAFiwVvWqygbcCHAB45jt8KMvwzpRxCvJLoFk4z6/VTzCf5zWNmpIgV
         /XVKDnrBwVEoSoOHZBmOiovlAavTd4uc2hdmG8cx+hN7i1cEY1PGd6wOgZrXYwHOIhyL
         AkGw==
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=N/CaV0KGLDIJNoKjpMO9TpiDCicZR8B6gLTsrk6xUYU=;
        b=LFU4TRD03wiKzWVm8g2Pj+8NuC38Q4vl/FPr7+DjQJC6oHtC9ObVc0s0IYBE9KWEU7
         IcpWEdSR2XrBUz2iosoUPCly1QZcV52D8HdHHBk8Z2sTzMiKQ47Euiwa+7thzuX9r7fm
         fnSIw2FbXzhmoQi9lzW+NJotrLXn/UYFIvveYFRT0fp7z7/S2Q8CUsMkA/LSGi6yUiIO
         EY772x2sh4ltslmLa/R9ASVOGBpopLaO3no4rWNHvfwn+UQUsbPGnAqEOFHAMG9nqJvZ
         ThmUwSGCETZgNVi8jav5GpSR6au5la55TfKhFOa2IRXhiQA/vpK7a78yw3mFFPUnZtXY
         JoGw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=FpH5DLxT;
       spf=pass (google.com: domain of tvaneerd@gmail.com designates 2607:f8b0:400d:c0d::231 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=N/CaV0KGLDIJNoKjpMO9TpiDCicZR8B6gLTsrk6xUYU=;
        b=V16408PFkbP5uz6PuJshQvBfk2dl/Jh3gi5QqOJVtIWGAywt2uLfPf1uJDW/TuCAVi
         xJAh6jiiql5CGnx1d6ufue0ldgumBIpZAN2Qq05aM4ghUF7r7/CSzFF7xPpTC1uxN4uc
         t/xsksACLdSB5jftdi5vYlXWEKjaElSDEEVFMIjmaxaC/aKYNR5/VUsPpkJDOAcLT2yp
         D+e34J/4YHPTqzwx9a1/zp+19d/TMNK8KoH1ACTTTyvj4Hdcdd7YE7KSeGxNtE2///fk
         gveAM5zOXB1ljvPAR0orXK+w5XEpM/U30J7lsEyjnZScCX4smR0i+CVFw7MguiyTLUPN
         ly2g==
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=N/CaV0KGLDIJNoKjpMO9TpiDCicZR8B6gLTsrk6xUYU=;
        b=T9F6O8SVhG2Rj2jLigNZzwkaed+3OSuscDOtSXg2o4b7PxWM+oL35aMz2klvXSONle
         8kcvtQlDhjc7b/1AhGFki3t3aWOgen56o+ADaLRV2yE5hvXJH1pHlZP+XIbX/8bQd4JB
         0jGm44IVpJvPVWXTTKePmXk/eklP4VDtQqx3bKExddBGKiKqCdXlW4C/byQJ044CtBDZ
         DAGO1saGMosjqwvPVyR6mNbYIOeIAli1Y4pLLPGqZYCk4NG6PbiEHXf8BEI7eimuCLm9
         Iufj9kLeY1Pjuftr0q4P5lDrHK3Btc5CrwPQAZRd/1+nDLBpzXmiLeN8mMIgKjoLui5M
         sRBg==
X-Gm-Message-State: AHYfb5hH+hBU9V5e09AWYhkFcWsxWN2OscK6Vk0JHY8XU5I+MX2prrj7
	ntLQC2zHUbqcDXkX
X-Received: by 10.200.53.50 with SMTP id y47mr6012676qtb.83.1502309829489;
        Wed, 09 Aug 2017 13:17:09 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.179.139 with SMTP id c133ls11141553iof.36.gmail; Wed, 09
 Aug 2017 13:17:08 -0700 (PDT)
X-Received: by 10.200.36.121 with SMTP id d54mr12818237qtd.171.1502309828291;
        Wed, 09 Aug 2017 13:17:08 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1502309828; cv=none;
        d=google.com; s=arc-20160816;
        b=lEus4wVuowQcnJkCgdFC2V52MjymkJ/ddPFUtKJ0MeuzeKxUtTqzk6wE2B6IHH3tcV
         CdDx89daCui+pXm2WwErt9a6XJFHYqf0+ewlTGYsasVnfqRgzLquvW+IP4WYqniF6Y57
         OmkQD7poOXGoyGPSh2bnsqCHeVnvdSDx4bFvWArlMArB64EpFbvdLUM/0w4h2LNxgp+Z
         mK0KA2i9BDXGbJP/wRmOZu5Wz8nmuf9UeRKL/8K3gLI6yBCDlTBSqMnICgtlJfs4f9By
         9R93szzugrffUzyauKJhX5aT7g7sZO5+seVkrya3IStlVVbo6XLl4s899nNkQ77Jt849
         6j1g==
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=b7yFPkvL9RlFo17QH550miYd7yZ+A1/Jjro7HjPqlm4=;
        b=kNbnt2SxPjcik8O4uy8XOGKvVXi1lw6Ef5X7TKjz3UY9AhYhhmsYYFKvZ0D8j4uDW5
         Hd1lab6GhAdSL2MelzjpHBGvoycSnwCxHi1YL0Rbm80/QSdj3CQeWXZsStNBtpj3OJ5B
         LJyjukYlKLtedDQrJKrXdAR9EtUOnRJqSFL4Uo7Dv0No6XREvSm5nEL93DbOFyWVhdmy
         1c2ViAJpUu8nnThk+8OLzSFfvBkad+InBPtpiQOse5mm7lhYpT47HbgT8xj1QTCjRfOK
         1q0xR6DFrcpjHDmfEW8q/eNecVxfabRVTBq6z8jLlyKdt9voUVK3NZfTzHvn980Avc+C
         rkxA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=FpH5DLxT;
       spf=pass (google.com: domain of tvaneerd@gmail.com designates 2607:f8b0:400d:c0d::231 as permitted sender) smtp.mailfrom=tvaneerd@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-qt0-x231.google.com (mail-qt0-x231.google.com. [2607:f8b0:400d:c0d::231])
        by mx.google.com with ESMTPS id 2si3788650qtp.523.2017.08.09.13.17.08
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 09 Aug 2017 13:17:08 -0700 (PDT)
Received-SPF: pass (google.com: domain of tvaneerd@gmail.com designates 2607:f8b0:400d:c0d::231 as permitted sender) client-ip=2607:f8b0:400d:c0d::231;
Original-Received: by mail-qt0-x231.google.com with SMTP id v29so43083569qtv.3
        for <std-proposals@isocpp.org>; Wed, 09 Aug 2017 13:17:08 -0700 (PDT)
X-Received: by 10.237.60.247 with SMTP id e52mr12509716qtf.106.1502309827906;
 Wed, 09 Aug 2017 13:17:07 -0700 (PDT)
Original-Received: by 10.237.42.10 with HTTP; Wed, 9 Aug 2017 13:17:07 -0700 (PDT)
In-Reply-To: <41733595.o4GQ0c89LU@tjmaciei-mobl1>
X-Original-Sender: tvaneerd@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=FpH5DLxT;       spf=pass
 (google.com: domain of tvaneerd@gmail.com designates 2607:f8b0:400d:c0d::231
 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:33742
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33742>

--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">&lt;<=
a href=3D"mailto:thiago@macieira.org" target=3D"_blank">thiago@macieira.org=
</a>&gt;</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>
&gt; So you have a pointer s, which is just an int, right?<br>
&gt; And all the cases are compile/link time constants...<br>
&gt; I&#39;m not sure that was valid C, but it worked.=C2=A0 Many years ago=
..<br>
&gt;<br>
&gt; Tony<br>
<br>
</span>Something like this?<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 switch (&quot;A&quot;) {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case &quot;A&quot;:<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 &quot;B&quot;:<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&#39;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) =
&amp;<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&#39;d say it&#39;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&#39;t guarantee what it returned.<br></div><div>(I think t=
he idea was that hitting the &quot;A&quot; 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=
&#39;t mean &quot;more than 20&quot; is incorrect, so I&#39;ll just keep te=
lling myself &quot;20&quot;, I&#39;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&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/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--

.
