220 18433 <mkt8iu$a00$1@ger.gmane.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Woehlke <mw_triad@users.sourceforge.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Thoughts on Exceptions, Expected, and Error Handling
Date: Fri, 05 Jun 2015 18:41:33 -0400
Lines: 50
Approved: news@gmane.org
Message-ID: <mkt8iu$a00$1@ger.gmane.org>
References: <b171ba85-b2cf-436a-9fa6-11525c186498@isocpp.org> <1d83a5df-f8b1-41fc-a197-319825b5436d@isocpp.org> <97c9b3aa-44b4-4a63-92a0-a571628b0735@isocpp.org> <CALQmNFj87ONznbZZM6uZGF-p70zAJogHA86t+iQctCRWS2b-jw@mail.gmail.com> <303e5cc6-8a3e-4063-880e-eac448ec0dc6@isocpp.org> <mkppe8$c1e$1@ger.gmane.org> <e2eb2c83-8060-442e-ac1e-ac820266787c@isocpp.org> <mksmts$k95$1@ger.gmane.org> <aaed4b27-37e3-48fa-aea1-c8e596447ccf@isocpp.org> <mksqqb$iau$1@ger.gmane.org> <d1a1020f-4c67-4b24-9e7e-8c2cb1f4b0da@isocpp.org> <557215EF.9060006@wanadoo.fr>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1433544159 11109 80.91.229.3 (5 Jun 2015 22:42:39 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 5 Jun 2015 22:42:39 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCO5FYHBU4ERBVOLZCVQKGQEW3LIKOA@isocpp.org Sat Jun 06 00:42:31 2015
Return-path: <std-proposals+bncBCO5FYHBU4ERBVOLZCVQKGQEW3LIKOA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wg0-f72.google.com ([74.125.82.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCO5FYHBU4ERBVOLZCVQKGQEW3LIKOA@isocpp.org>)
	id 1Z10Jq-0008UM-N9
	for gclcip-std-proposals@m.gmane.org; Sat, 06 Jun 2015 00:42:30 +0200
Original-Received: by wgez8 with SMTP id z8sf20635280wge.2
        for <gclcip-std-proposals@m.gmane.org>; Fri, 05 Jun 2015 15:42:30 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:to:from:subject:date:lines:message-id:references
         :mime-version:content-type:content-transfer-encoding:user-agent
         :in-reply-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=uACLcRGDNvd9mqniYia0bOcpXybmILZASlZ+5FKrVPs=;
        b=hf+iRRV9p8p5FyyaQ21ZEh864hVclZECbXaDiqDRF1b7vxIw2hUuqz0ttCJU55j0d5
         JA2yyYoTcg53V4qe2DS6IzvTP5lW4FK/qCbKr4NwoLlMwlj5GShcXHt2yt9PSQAokULv
         4yDvOqBJBGPMH33PppN5d7ELn0eKsro0r2ngRm9fkAU2ydcshA9Zl4/Zb+p5onBsoOlw
         jkM3vTTUaNIxLJsuHHqMnSZxdTFTNjAw6YDGM2x8Rvtxwl/teI9TFtFlufxyrRM31SiN
         OKH3kyx+qO/7IwiBIQTW9Ly0+40StMAgqwr43M9Iu/0Xd54wa+X9TxEMxmstApOQAzah
       
X-Gm-Message-State: ALoCoQllDePWnh+nyKT9ya72oJ83vempwow4bKCcibr17Yk2EYhlj4zGbgDEqXZ0/IDAoowja8tn
X-Received: by 10.180.216.12 with SMTP id om12mr475037wic.1.1433544150099;
        Fri, 05 Jun 2015 15:42:30 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.203.133 with SMTP id kq5ls406724lac.102.gmail; Fri, 05 Jun
 2015 15:42:28 -0700 (PDT)
X-Received: by 10.152.30.4 with SMTP id o4mr5248931lah.74.1433544148437;
        Fri, 05 Jun 2015 15:42:28 -0700 (PDT)
Original-Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by mx.google.com with ESMTPS id mk8si5911113lbb.129.2015.06.05.15.42.28
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Fri, 05 Jun 2015 15:42:28 -0700 (PDT)
Received-SPF: pass (google.com: domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as permitted sender) client-ip=80.91.229.3;
Original-Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <gclcip-std-proposals@m.gmane.org>)
	id 1Z10JZ-0008Hr-Kt
	for std-proposals@isocpp.org; Sat, 06 Jun 2015 00:42:14 +0200
Original-Received: from tripoint.kitware.com ([66.194.253.20])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Sat, 06 Jun 2015 00:42:13 +0200
Original-Received: from mw_triad by tripoint.kitware.com with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Sat, 06 Jun 2015 00:42:13 +0200
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 38
Original-X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: tripoint.kitware.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To: <557215EF.9060006@wanadoo.fr>
X-Original-Sender: mw_triad@users.sourceforge.net
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as
 permitted sender) smtp.mail=gclcip-std-proposals@m.gmane.org
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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:18433
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18433>

On 2015-06-05 17:34, Vicente J. Botet Escriba wrote:
> Le 05/06/15 21:19, Nicol Bolas a =C3=A9crit :
>> OK, so... what about static analysis tools? We already have great
>> static tools that can detect the use of many uninitialized values.
>
> expected as optional, and I hope would variant, are never uninitialized
> as these classes have default constructor.

Not the expected/optional itself, but the contained value.

IOW, this is a (potential) error:

  auto x =3D function_that_returns_expected_or_optional;
  do_something(x.value());

....because you didn't check that 'x' actually *has* a value, and thus
value() might throw.

Nicol is of the opinion that one should never write code like this, even
if throwing from the context where value() is called if there is no
value is the intended behavior.

I have to ask, though: in that case, why throw at all?

Really, I envision expected as a 'delayed throw' mechanism. The point is
to return an expected instead of throwing immediately, and instead delay
*the throw that otherwise would have happened* until the user calls
value(), thus giving a window where the user can choose to handle the
error before an exception is thrown.

If you're *not* going to implement it that way, then why even throw an
exception? Why not just terminate the program? Or make it UB? IMO it's
*much* more useful for expected to be an exception delaying mechanism
than to do something that (by Nicol's assertion) is useless and
can/should only ever result in program termination.

--=20
Matthew

--=20

---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.
