220 35958 <CAC+0CCN7mFF1hiPPyUetL0mNaOkrjkhpsSv2QxXBfUfLzVqK8g@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Jake Arkinstall <jake.arkinstall@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: auto return proposal
Date: Sun, 17 Dec 2017 19:54:41 +0000
Lines: 91
Approved: news@gmane.org
Message-ID: <CAC+0CCN7mFF1hiPPyUetL0mNaOkrjkhpsSv2QxXBfUfLzVqK8g@mail.gmail.com>
References: <CAB+4KHJCie_iwSm5OQVaHfsutdVJVbBo3ALecvn1ibsKg4uDTQ@mail.gmail.com>
 <efd8b147-9992-4c1d-8248-86c5bba73016@isocpp.org> <CAC+0CCPdXyd+vSP0wpv-g66DHxBsRg06hdmwAPDQR0XXaYKVyg@mail.gmail.com>
 <c459b643-71d1-4b77-afe1-328a760847ea@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a113adaa4c98ae805608e9a8d"
X-Trace: blaine.gmane.org 1513540366 21779 195.159.176.226 (17 Dec 2017 19:52:46 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 17 Dec 2017 19:52:46 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDCZX3WUUQFRBAUX3PIQKGQE6TWYAUQ@isocpp.org Sun Dec 17 20:52:42 2017
Return-path: <std-proposals+bncBDCZX3WUUQFRBAUX3PIQKGQE6TWYAUQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ot0-f200.google.com ([74.125.82.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDCZX3WUUQFRBAUX3PIQKGQE6TWYAUQ@isocpp.org>)
	id 1eQezJ-0005KI-RK
	for gclcip-std-proposals@m.gmane.org; Sun, 17 Dec 2017 20:52:42 +0100
Original-Received: by mail-ot0-f200.google.com with SMTP id u10sf7939893otc.21
        for <gclcip-std-proposals@m.gmane.org>; Sun, 17 Dec 2017 11:54:44 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1513540483; cv=pass;
        d=google.com; s=arc-20160816;
        b=lXbcA1J96mJDbCN55Gb0U3/L1TbkhmjKX2CINPzIeU8ZUvG2vC8rLrVWbmJ3ou2Bil
         pAmg7aRNISqJhKDHGqbM7xVidauPpPdTd9Ykk/hy6GjGTQEyGLQv0BIhHuwLLmEQ+5+0
         rOb3Ua5TJ8ZEKv4fqzJpMb8XgO5VVS1GFQe41GmdklCq2exUxZDwpZkIYrykqnjglAAV
         4PQrcnjVbY+ftgQhxAMcvYS17acZIVOK8xhpIj5CEJ6obUHJjjd4WkvSbbPKskrTtWWr
         z7JS0EjqNIYpC4pLeBc6++dPRgSSbgKqOjbHXOL2mLXHb1kqf7FUl4PW1dR25VrsJltN
         XBYw==
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=ZahwISkeGMfFBuOnyEPU9zJeYMnmI13ZFxNpRhLIdx8=;
        b=slr725yGmiKVnDxOf/DH3FXTBb3elmPhrqddvJUA8JAouThKLqOfoR4MlD8fgb1fgC
         y/4Reze3UNig9GSkJA0rnHX8rEidRbhISJTjWWkQ3vreBKYoLOP9hAAgIe2wP0ulgfgi
         oupdI58wrOtLtJBq4tU8GhPsJC5OqR366Z99iNeCuyYo6jknuqWeQKUogXBlcunL8OFS
         1pXF3IbDVS8J+q5ngJDzMpxl2YS5xulUoWg2A8p4oiLlESKaiCff889wsYxJWdEk5nwl
         mt7jyYjQVAr2PWVOh1QkJ5fR5bnxysNGGtfpRyiFFlxlwE62pQ7/WpMxKrOwCs74TnLL
         aG3g==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=GIgO9tMU;
       spf=pass (google.com: domain of jake.arkinstall@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jake.arkinstall@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=ZahwISkeGMfFBuOnyEPU9zJeYMnmI13ZFxNpRhLIdx8=;
        b=qBThJ0MnUPXK6n0kU6I+O613MEX5vBuhNt+xwVuqMlw1GUIH+zBl/4Qn4xzpBMwUgz
         trATMdV7nWqWf+kQS5VSTapq8hNPw8DthcWBJedErL4WrRod1v0Yv+7dIzf8HF9okvCB
         ZkVWITlvDT+v5StDuSLvmLEXdrK6Omucaf5NSf9wlgYjXl/cFETOdPYclhkUXOML6Yt7
         IqiCgCgg6inDqXeWEMwQGBkX4wLd8CzGJMilrjL9CblBH7kNYkmDE3xlWCcRGTqC6fuw
         lt4mdXqP+JFhEkZYIgH0J8Ef3yhKcHKhuNAy5MeSQNLwO2aavg1JBF9oaGveLgarmIO6
         RjMA==
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=ZahwISkeGMfFBuOnyEPU9zJeYMnmI13ZFxNpRhLIdx8=;
        b=BBXTonc+oT4AbwX7CXi7QcFeRW9tPxDp2+q2nMt8Yd8/v9OMH61L9bsor7DBZZU7Gc
         8HQalZnUKqmTMS+6aS/baIWY55cmabDBW+3GFdabsKLn94Sp3kfnRpfHcMAkuAVCW64J
         Fp553xx2Gw4QjIn83B7tVb4ZRNF7p4uJ6L8rc7MLz1BPSZ/iaA/kBAHjZTID7V4g0W6N
         lzP+3M8fyQZReqkp4cQ6kzCiBOmyYpeMWf5ES+k5X5F1fGLHhDKumyX/JpJhBfRXS6kD
         lYLDglWecqtUDldBCCS0I4nNEHAUKLBR0RQfP178r7zWu79MZex3MxWriuHR7pytT5hV
         Q8QA==
X-Gm-Message-State: AKGB3mIYTM3Go2XiU9Edt0edg8sfK2jJ+XB23OLJrlLzl7EcpkACCG9P
	ukFL+CSrHfgGBUoYqBu1oATKdQ==
X-Google-Smtp-Source: ACJfBouO7PsUiQRoejkPUbHAZurPY2rFE6Q/lWpwUbEH1AhEu3ct9VRNXNrLoUxPl+6pUuNXAI5jdw==
X-Received: by 10.202.98.197 with SMTP id w188mr7345331oib.125.1513540483815;
        Sun, 17 Dec 2017 11:54:43 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.41.138 with SMTP id n10ls3716915otb.5.gmail; Sun, 17 Dec
 2017 11:54:42 -0800 (PST)
X-Received: by 10.157.91.15 with SMTP id x15mr14525832oth.78.1513540482608;
        Sun, 17 Dec 2017 11:54:42 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1513540482; cv=none;
        d=google.com; s=arc-20160816;
        b=jDvBymAuhBLD3jzoEqKXfH4tKmqImD5E16A8Dhf+PO1WsPIz+MJcaY2SCDM2kYaI53
         mrnj0Tz3QvPFcWiUbJJtODoIg20h7bpa+4qxHoNhmFwzZOHrVM9aIxtLZs/iK9/azFmp
         8lh/U7t+mdN/JQNdJXwJqJKMIfc+LFwlcvhB48TH3448TFyfPMFndv45hbqH1YicWfPm
         9DKh/s7p3bKybh4HABr8H8O7WX0xGJxCguKLbXudACju9CgePbNMS5WpYAuYPnJgpkKn
         uTay18oz7u2gSuectU+jJVouC8ctLd8yzg19eLRRGCHWyr+KiR7MnHcT/zL1vycV++Ql
         HyZg==
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=FJrqJyhBmq0jNlyURVBo5slrWF0ruDjqkCHXZzvYnWg=;
        b=M+5PiaufjEkUMpQ0mgN9iECrtCOQNIScp5qhejbUxDXFXOlzDltFxVlHmjdPIsR04s
         WaD4WDoc3PkBwBkRVW0dWlEyfErAQmG6JrnypHuRGrkSM+y+MFl5THGz1Xe2ZyGgt8jo
         bJq8oRWLfTtPtPTF8lMF/Ckiwq54DlyDNScjh/mIIkMPX8/2wfgcCwF2WqYp6vEhdPwB
         EM4yw99VZgzHfrg0nT3yGK4yNIzCvuxzLmVFZfMZG6IDyehyR1yCiqoUFJO3//+DH0HW
         P9Aad9JW30mKyUIPsM/rbRcTDsX8RQtFBpDeUCyIFAk5uXfpAYSUlkfh+9JfhhARfAWl
         dpGg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=GIgO9tMU;
       spf=pass (google.com: domain of jake.arkinstall@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jake.arkinstall@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id u184sor3976344oig.162.2017.12.17.11.54.42
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sun, 17 Dec 2017 11:54:42 -0800 (PST)
Received-SPF: pass (google.com: domain of jake.arkinstall@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.202.213.76 with SMTP id m73mr12378356oig.79.1513540482073;
 Sun, 17 Dec 2017 11:54:42 -0800 (PST)
Original-Received: by 10.168.69.140 with HTTP; Sun, 17 Dec 2017 11:54:41 -0800 (PST)
Original-Received: by 10.168.69.140 with HTTP; Sun, 17 Dec 2017 11:54:41 -0800 (PST)
In-Reply-To: <c459b643-71d1-4b77-afe1-328a760847ea@isocpp.org>
X-Original-Sender: jake.arkinstall@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=GIgO9tMU;       spf=pass
 (google.com: domain of jake.arkinstall@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=jake.arkinstall@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-Spam-Checked-In-Group: 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:35958
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35958>

--001a113adaa4c98ae805608e9a8d
Content-Type: text/plain; charset="UTF-8"

On 17 Dec 2017 18:09, "Nicol Bolas" <jmckesson@gmail.com> wrote:

If the user passes an inappropriate `value`, then that's on them and you
want UB to happen.


I'm not sure on that. It almost seems like a perfect place for a Maybe
monad.

And if `T` is not default-constructible, then the only thing you can do is
`throw` (or use something like `expected`). And what if you don't want to?
What if you want the narrow contract?


If you want a function that does return something useful iff the argument
makes sense, that's THE use case of std::invalid_argument. This is a
function that works all the time, 99% of the time.

Perhaps a definite return or throw is one option. I can't see how your
example is in any way made worse by adding a throw at the end, and at least
the user finds out what they did wrong. Providing them with a program that
seems to be running fine before it goes crazy at a later point isn't
helpful to anyone.

I certainly agree that giving the programmer the flexibility of making
assumptions is useful, though, and I'm wondering if a keyword to allow
non-returning branches would make sense. I don't have a particularly strong
position on this, though. It makes sense to leave this to the discretion of
the compiler writers if it's too controversial.

-- 
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/CAC%2B0CCN7mFF1hiPPyUetL0mNaOkrjkhpsSv2QxXBfUfLzVqK8g%40mail.gmail.com.

--001a113adaa4c98ae805608e9a8d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><div class=3D"gmail_extra"><div class=3D"gmail_quote=
">On 17 Dec 2017 18:09, &quot;Nicol Bolas&quot; &lt;<a href=3D"mailto:jmcke=
sson@gmail.com">jmckesson@gmail.com</a>&gt; wrote:<br type=3D"attribution">=
<blockquote class=3D"quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"ltr"><div>If the user passes an inappr=
opriate `value`, then that&#39;s on them and you want UB to happen.</div><d=
iv></div></div></blockquote></div></div></div><div dir=3D"auto"><br></div><=
div dir=3D"auto">I&#39;m not sure on that. It almost seems like a perfect p=
lace for a Maybe monad.</div><div dir=3D"auto"><br></div><div dir=3D"auto">=
<div class=3D"gmail_extra"><div class=3D"gmail_quote"><blockquote class=3D"=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr"><div>And if `T` is not default-constructible, then the=
 only thing you can do is `throw` (or use something like `expected`). And w=
hat if you don&#39;t want to? What if you want the narrow contract?<br></di=
v></div></blockquote></div></div></div><div dir=3D"auto"><br></div><div dir=
=3D"auto">If you want a function that does return something useful iff the =
argument makes sense, that&#39;s THE use case of std::invalid_argument. Thi=
s is a function that works all the time, 99% of the time.</div><div dir=3D"=
auto"><br></div><div dir=3D"auto">Perhaps a definite return or throw is one=
 option. I can&#39;t see how your example is in any way made worse by addin=
g a throw at the end, and at least the user finds out what they did wrong. =
Providing them with a program that seems to be running fine before it goes =
crazy at a later point isn&#39;t helpful to anyone.</div><div dir=3D"auto">=
<br></div><div dir=3D"auto">I certainly agree that giving the programmer th=
e flexibility of making assumptions is useful, though, and I&#39;m wonderin=
g if a keyword to allow non-returning branches would make sense. I don&#39;=
t have a particularly strong position on this, though. It makes sense to le=
ave this to the discretion of the compiler writers if it&#39;s too controve=
rsial.</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/CAC%2B0CCN7mFF1hiPPyUetL0mNaOkrjkhpsS=
v2QxXBfUfLzVqK8g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCN7mFF1=
hiPPyUetL0mNaOkrjkhpsSv2QxXBfUfLzVqK8g%40mail.gmail.com</a>.<br />

--001a113adaa4c98ae805608e9a8d--

.
