220 30462 <e85f0d46-f244-42fe-a276-b4e18b3d627f@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: enum_cast proposal
Date: Tue, 10 Jan 2017 08:20:11 -0800 (PST)
Lines: 93
Approved: news@gmane.org
Message-ID: <e85f0d46-f244-42fe-a276-b4e18b3d627f@isocpp.org>
References: <efdf2357-00a6-408a-8772-12f99135a880@isocpp.org>
 <57258435-5d82-48e7-8ed7-3c38682418fb@isocpp.org>
 <a35d9f20-9e4f-4789-b7e5-5cb08f99e6bd@isocpp.org>
 <58750288.5080004@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_5088_1591528047.1484065211089"
X-Trace: blaine.gmane.org 1484065218 2286 195.159.176.226 (10 Jan 2017 16:20:18 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 10 Jan 2017 16:20:18 +0000 (UTC)
Cc: m.cencora@gmail.com, gmisocpp@gmail.com, mwoehlke.floss@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBPET2TBQKGQEUSWCZEQ@isocpp.org Tue Jan 10 17:20:10 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBPET2TBQKGQEUSWCZEQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f197.google.com ([209.85.223.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBPET2TBQKGQEUSWCZEQ@isocpp.org>)
	id 1cQz9c-0008E4-OP
	for gclcip-std-proposals@m.gmane.org; Tue, 10 Jan 2017 17:20:08 +0100
Original-Received: by mail-io0-f197.google.com with SMTP id 101sf112077988iom.7
        for <gclcip-std-proposals@m.gmane.org>; Tue, 10 Jan 2017 08:20:13 -0800 (PST)
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:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=xm2BIUq/ZQY2v0rloRvLkXarItZCr2QPT7w9mlAukTU=;
        b=qFj0zPPypT2i5kAQRJZ+k3ADLcSGi/FZ1FsYGb3cYmcY4ehRlVurBBUUby9/Xtgb/j
         n4wYhNgTfEnhfMBpWeyoCc/RuHybcsfCFU6qJUhsz8WBYkg9Ms+3ZiU42ylAH2bZoLIx
         fvfud4F402qxF7ldzB7MjYLRTyIJtqK+loQ/n7oo2sZfGXztOF3HUbbnbHp0ZDXaQUbe
         noGm195+UhAPmnmAv27Fhn0IB4/r9/clzXPnIPmMluGbtEAYAcxNrscCZVWxupP0eCa6
         W0DNAx3LhOTHXk/6/W+YYdvJQcjcbtPmNzTiAAEcYyzYvF8H5udyEzPg6GsaQYo9qxI/
         zVDQ==
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:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=xm2BIUq/ZQY2v0rloRvLkXarItZCr2QPT7w9mlAukTU=;
        b=fs2zJxfrIn66LSKaqiF4Nbrd3P3C5KDte6HF1Ul/bcgBk+A/8qREhm+H64l+aYBVZh
         riyo5GmE9/uadirvQVr98vrxf9Db+GUB2LIbE+MwBS6w0x0gdTMouP+HfLK42EYql2f1
         YQEilMYplWgJJbO9fI7Nni6TBHq8ceWho/tvTySjdwd9pLl63fv5AmwUV2bhLYXXMBhu
         2U5sVyoQB3ki+mWsmflfcugAEM/YeRJ6Vdhy6qKX5S/yZ8ZssdHuT0Ib48v49Y5c+Ec6
         LBAKQh2x3NL/bYDbtwR7KyUIQdDhUXpoFw2IeY4uQMu9SmZDcjXiMFM3sgBxhhXSF/YZ
         zE3Q==
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=xm2BIUq/ZQY2v0rloRvLkXarItZCr2QPT7w9mlAukTU=;
        b=QDAGXG6yEgHrMSa0vb0wnFyzi7ZXdfIH1zQD4iMHR2/wrazopoCIJSk9Szooh5Dj02
         lxetxaY1+t7uoaGFUecXeXyXOp1cZWq+lc2MZGoheQON79hAAqQ2sXXZD4ztIg8zcQd2
         +a6SZkDYDb0PtghvfhXZ58QP99aO/UMR3UFuYbOfJfiu7+ZSIHQNxk4EARo/aFmh6wMb
         U/Y+pUhl0LkFatVGaW8lrhhF+6UTjHurqlfG7Jlu0jgh4YM16BjlhY7u2+x1N60v3OK2
         FPLvyDQLkbkrWHxddWwldTACPe8p+Aiz5e890XKBG/PcBtWFUZIJi46+KIbB3c5iJuA1
         bw3w==
X-Gm-Message-State: AIkVDXLmQtlTT6I9U2BAIHFy7VIxuTP1lGq/Cn/Mk96dpVcdOhe4Iz0nxbJ3ff+SqPb40Q==
X-Received: by 10.36.67.3 with SMTP id s3mr1088093itb.0.1484065213152;
        Tue, 10 Jan 2017 08:20:13 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.2.1 with SMTP id 1ls134942otb.26.gmail; Tue, 10 Jan 2017
 08:20:12 -0800 (PST)
X-Received: by 10.157.8.134 with SMTP id 6mr258981otf.17.1484065212490;
        Tue, 10 Jan 2017 08:20:12 -0800 (PST)
In-Reply-To: <58750288.5080004@gmail.com>
X-Original-Sender: jmckesson@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:30462
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30462>

------=_Part_5088_1591528047.1484065211089
Content-Type: multipart/alternative; 
	boundary="----=_Part_5089_1816503418.1484065211089"

------=_Part_5089_1816503418.1484065211089
Content-Type: text/plain; charset=UTF-8

On Tuesday, January 10, 2017 at 10:49:34 AM UTC-5, Matthew Woehlke wrote:
>
> On 2017-01-10 10:31, m.ce...@gmail.com <javascript:> wrote: 
> > For sure baseline API must be exception-free. 
> > Do we really want to additionally support API that throws on error? 
>
> I *really* hope we can use something like std::expected; this is a 
> textbook use case for that, and makes it trivial to have a 
> throw-on-error API (just grab the value from the expected without 
> checking it first; this will turn around and throw if the value is not 
> there).
>

But the fact that it's throwing the wrong exception makes it useless from 
an exception handling perspective. If you want an API to throw, you want it 
to throw a *meaningful* exception type, not the same kind of exception that 
20 other APIs throw.

So yes, we really do need to support a throwing API. I say we should have 3 
interfaces:

* `can_enum_cast`: specifies whether the value is in an enumeration. This 
is where the compiler magic comes in, of course.
* `enum_cast`: Converts to the enumeration type, or throws if it cannot.
* `enum_cast_opt`: Returns an `optional<Enum>`.

The first allows you to build whatever tools you want. But we have default 
tools for C++'s standard mechanisms: throwing and `optional`.

-- 
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/e85f0d46-f244-42fe-a276-b4e18b3d627f%40isocpp.org.

------=_Part_5089_1816503418.1484065211089
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, January 10, 2017 at 10:49:34 AM UTC-5, Matthew=
 Woehlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2017-01-10 1=
0:31, <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"BG=
0SGbfzBQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#3=
9;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;"=
>m.ce...@gmail.com</a> wrote:
<br>&gt; For sure baseline API must be exception-free.
<br>&gt; Do we really want to additionally support API that throws on error=
?
<br>
<br>I *really* hope we can use something like std::expected; this is a
<br>textbook use case for that, and makes it trivial to have a
<br>throw-on-error API (just grab the value from the expected without
<br>checking it first; this will turn around and throw if the value is not
<br>there).<br></blockquote><div><br>But the fact that it&#39;s throwing th=
e wrong exception makes it useless from an exception handling perspective. =
If you want an API to throw, you want it to throw a <i>meaningful</i> excep=
tion type, not the same kind of exception that 20 other APIs throw.<br><br>=
So yes, we really do need to support a throwing API. I say we should have 3=
 interfaces:<br><br>* `can_enum_cast`: specifies whether the value is in an=
 enumeration. This is where the compiler magic comes in, of course.<br>* `e=
num_cast`: Converts to the enumeration type, or throws if it cannot.<br>* `=
enum_cast_opt`: Returns an `optional&lt;Enum&gt;`.<br><br>The first allows =
you to build whatever tools you want. But we have default tools for C++&#39=
;s standard mechanisms: throwing and `optional`.<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/e85f0d46-f244-42fe-a276-b4e18b3d627f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e85f0d46-f244-42fe-a276-b4e18b3d627f=
%40isocpp.org</a>.<br />

------=_Part_5089_1816503418.1484065211089--

------=_Part_5088_1591528047.1484065211089--

.
