220 18372 <mkndu3$f9j$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: Wed, 03 Jun 2015 13:36:03 -0400
Lines: 52
Approved: news@gmane.org
Message-ID: <mkndu3$f9j$1@ger.gmane.org>
References: <b171ba85-b2cf-436a-9fa6-11525c186498@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1433353010 18951 80.91.229.3 (3 Jun 2015 17:36:50 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 3 Jun 2015 17:36:50 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCO5FYHBU4ERBI7WXSVQKGQEQTXWLLI@isocpp.org Wed Jun 03 19:36:37 2015
Return-path: <std-proposals+bncBCO5FYHBU4ERBI7WXSVQKGQEQTXWLLI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wi0-f198.google.com ([209.85.212.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCO5FYHBU4ERBI7WXSVQKGQEQTXWLLI@isocpp.org>)
	id 1Z0Cai-0000XI-VA
	for gclcip-std-proposals@m.gmane.org; Wed, 03 Jun 2015 19:36:37 +0200
Original-Received: by wibbk2 with SMTP id bk2sf7134517wib.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 03 Jun 2015 10:36:36 -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: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=mJkFsyH5Qbif0rFc0lXvFMAagEPzU4VfyAIm1cJqBB4=;
        b=IYHLk4KAjeqSwV0eYYVwsFiIF7uxA6HlWq5z8sPP2EdVF1mZPGmUmDICf3zo3FCh+v
         /64JrgAltPTCEGthYrTpUE9U/vmF384AICrkKSckeb6zwGlQjqi4VX6yI5kiEE85/TWB
         iVAv2QxIv7jx4ZEfZixykhtzzqiUDqHrtKgc5qupG+mDb0bMnH8o1mCbfVz9K9sKG9bO
         Rjssp2QF4GxXi7zH2z1iTGI1VsIXIua+zXo8vvgLUiJahXlbwJKJ/TwYsXTG3GpaqIN2
         9LqHf9C47f0FYYDDb11HoA+EesGEcIlmdczYJHQ5wT9MU0JmQWH7FDHWlNhzPR6HdmLq
         lEUw==
X-Gm-Message-State: ALoCoQk2bXPKByZ8LUWe6oSsxbvpdVSG3YiBeUMKMGWICGdjm7xldJjmA0JuU7iHoqhEKsYma+lN
X-Received: by 10.112.26.5 with SMTP id h5mr31907827lbg.4.1433352996507;
        Wed, 03 Jun 2015 10:36:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.28.4 with SMTP id x4ls104550lag.40.gmail; Wed, 03 Jun 2015
 10:36:35 -0700 (PDT)
X-Received: by 10.112.137.1 with SMTP id qe1mr32411549lbb.22.1433352995126;
        Wed, 03 Jun 2015 10:36:35 -0700 (PDT)
Original-Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by mx.google.com with ESMTPS id r2si4591599lar.46.2015.06.03.10.36.35
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Wed, 03 Jun 2015 10:36:35 -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 1Z0CaY-0000OR-BF
	for std-proposals@isocpp.org; Wed, 03 Jun 2015 19:36:26 +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>; Wed, 03 Jun 2015 19:36:26 +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>; Wed, 03 Jun 2015 19:36:26 +0200
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 43
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: <b171ba85-b2cf-436a-9fa6-11525c186498@isocpp.org>
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:18372
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18372>

On 2015-06-03 01:09, Nicol Bolas wrote:
> However, everything that `error_condition` can do is based purely on the 
> type of `error_category` it uses and an integer. Now, consider parsing 
> integers. If a parse error occurs, the parsing system knows a lot of very 
> useful information about it. It knows how many characters it successfully 
> read. It knows exactly which character caused that error. And so forth.
> 
> All of that information is *lost* when you reduce the error to a number.

Actually, if the caller passed in an output parameter to receive the end
pointer (which would not be an unusual use case), the caller would still
be able to construct your better exception.

I'm not convinced this is an argument against 'expected', though it
sounds like a reasonable argument against 'expected<T, error_code>' in
some contexts that I think deserves consideration.

> But if you start throwing around an `expected<int, big_giant_object>`

If you're storing big_giant_object inline rather than as some sort of
smart pointer, you're doing it wrong :-). (And indeed, since you're
storing it *by value*, and one or the other is AFAIK required, in this
case it might make sense for expected itself to store big_giant_object
as a pointer, whose nullness or not indicates if it has an int or a
big_giant_object.)

> And then there are things that `expected` flat-out cannot handle or handles 
> very poorly.
> 
> The first is any function that doesn't return a value. Oh yes, 
> `expected<void, ec>` exists. But it would be rather... foolish to expect 
> everyone to do that. Uniformly.
>
> The same applies to any function that returns a value that most users will 
> drop on the floor.

Neither of these are cases that 'expected' is meant to solve, and it's
clearly the wrong tool in both cases. These - especially the second -
are cases where you want a 'checked result' type if just throwing in the
first place is not an option.

-- 
Matthew

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
