220 30040 <0cfcac6f-4d8a-40f2-9fc7-cf82c65db117@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: decltype(return)
Date: Tue, 27 Dec 2016 07:04:45 -0800 (PST)
Lines: 189
Approved: news@gmane.org
Message-ID: <0cfcac6f-4d8a-40f2-9fc7-cf82c65db117@isocpp.org>
References: <658f00ff-7a02-7c04-3fcb-6ac7f45b777b@scylladb.com>
 <CAKqmYPbB4Drfrz2ZUbFnJP+aSwdW2AGfj+WVvPaP7Ge1PiyyeA@mail.gmail.com> <425f6577-b92d-40f3-8d0d-64668351edf5@isocpp.org>
 <CAKqmYPag-x0esrhJg7vjerjtQA7GJyN4KycqtOh9+202P4YGRg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1043_1940871803.1482851085850"
X-Trace: blaine.gmane.org 1482851093 11670 195.159.176.226 (27 Dec 2016 15:04:53 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 27 Dec 2016 15:04:53 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBDUGRLBQKGQEVCG6ZYI@isocpp.org Tue Dec 27 16:04:45 2016
Return-path: <std-proposals+bncBCEKFTV6ZUMBBDUGRLBQKGQEVCG6ZYI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f70.google.com ([74.125.83.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBDUGRLBQKGQEVCG6ZYI@isocpp.org>)
	id 1cLtIw-0001m7-Sk
	for gclcip-std-proposals@m.gmane.org; Tue, 27 Dec 2016 16:04:43 +0100
Original-Received: by mail-pg0-f70.google.com with SMTP id f188sf1003392133pgc.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 27 Dec 2016 07:04:47 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to: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=fZBk/qRI8woR7RIy8eWq/zRPdwj27UnMcKUCJgNGk0s=;
        b=UmcZRLFd60KCP5IT9KlVnDPj7znk6Jf8kusXhzK1Zl+5JzYQTllKE1DewbnfVeulRm
         wTwkvdjgQ6nRqYF83eMkNhAQwDZTb6VVN1MNtd+GzkVhzZKTWkuMoVNGt5n37tEa3/Q/
         MbjMb3g4NxGJnd3+sVFCswFopJNFhCBKuDnT4uCv4ToU7mALnXB7JsJaWrDBtCDMi1Eb
         7WmzEhRUpIPQ0vYln1nK1BOqg3SXBbWZywZ3Ht1JPjCyHbkz1Fheh5HZ2a0E8WVo0SR/
         dD49aLDq4bbKvrVy1m70d0qye7L5kjVP36MEQVKWzecmk9Yde+EzZxiBm8/2ypZNybD1
         IO5w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to: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=fZBk/qRI8woR7RIy8eWq/zRPdwj27UnMcKUCJgNGk0s=;
        b=euMkt7+C+5aKF5vifpNVEhhRcwlKh3Ki72lGnspC/F9VXeS0BLZ2QTWhykafG04u7b
         PhJqWODVga7H/qTZ+tEZo21XIT8+JH/Mr9ZJPLHpf0ej4XntRDUYCInPZqZku4sK7j57
         QrrvIvS0Hat3QKdf/bkI8RMshpxe4KmmIdn6vF1yVsQ2uk4NzhoHqelYMj3MLA6jFCss
         p2ZMkqhSg7X//YzVvN6UGQXb8iy2DASvAnZgiYClFXRxvBiSyfb7uZ/ekSQDUCCXDhLp
         vNiLmZ1cK76KDSha/0gR64B9ia5RL82s/t2Rz2D5mAuA9+Iuj7TaZrVhQFk0fsaDbXLy
         7mcw==
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: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=fZBk/qRI8woR7RIy8eWq/zRPdwj27UnMcKUCJgNGk0s=;
        b=Xjwoi4dDIrw+DO+7z/jJIlMDLswb+dq6JX/LOFfeS3Dq/aFqDL/PegtYS1fZT9jdQZ
         IuZ0x+BVcy297pslVhH/KRuvwb911J3CeiB5lONGaRobxq5jL7G1jzkfsgr0AeSIdduG
         1YLX8PrZuibdhjWvW2PX+hFbR8JZTWCgNU3QvhsYL7fIgrmmiYujKw4bJVFJ9ujXP/NJ
         sJf37yOm244jRZsLKnodqYppYAUmZJYQX/20gToFMwe56RznnIKazQe2kTiF+KlpylQL
         JUvXZkHfXXn/lijFz22I7nCpxJNZmtXkQKLJjFQvnvfcaqctITu+k4NJOMA37PHQe0nt
         3T8g==
X-Gm-Message-State: AIkVDXLRxmzNw9dYt8pznVMTJC9qwLh/FCJyRUN31MN65fL64NejFXxoG21ufqt1O8TJzA==
X-Received: by 10.99.184.18 with SMTP id p18mr19180618pge.126.1482851087180;
        Tue, 27 Dec 2016 07:04:47 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.43.168 with SMTP id u37ls22667771ota.29.gmail; Tue, 27 Dec
 2016 07:04:46 -0800 (PST)
X-Received: by 10.157.49.66 with SMTP id v2mr1610461otd.19.1482851086379;
        Tue, 27 Dec 2016 07:04:46 -0800 (PST)
In-Reply-To: <CAKqmYPag-x0esrhJg7vjerjtQA7GJyN4KycqtOh9+202P4YGRg@mail.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:30040
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30040>

------=_Part_1043_1940871803.1482851085850
Content-Type: multipart/alternative; 
	boundary="----=_Part_1044_2021313351.1482851085850"

------=_Part_1044_2021313351.1482851085850
Content-Type: text/plain; charset=UTF-8

On Tuesday, December 27, 2016 at 12:43:11 AM UTC-5, Antony Polukhin wrote:
>
> 2016-12-25 22:27 GMT+03:00 Nicol Bolas <jmck...@gmail.com <javascript:>>: 
> > 
> > 
> > On Sunday, December 25, 2016 at 2:13:57 PM UTC-5, Antony Polukhin wrote: 
> >> 
> >> 2016-11-18 19:01 GMT+03:00 Avi Kivity <a...@scylladb.com>: 
> >> > 
> >> > map<foo, map<set<bar>, baz>> 
> >> > complicated(...) { 
> >> >     decltype(return) ret; 
> >> >     // add stuff to ret 
> >> >     return try; 
> >> > } 
> >> > 
> >> > Instead of repeating the complicated type, refer to it via 
> >> > decltype(return). 
> >> > Won't work with deduced return types, of course. 
> >> 
> >> Syntax sugar makes the language harder to understand. 
> > 
> > 
> > No, it doesn't. `for` loops are syntactic sugar for `while` loops. 
> > Range-based `for` loops are syntactic sugar for `for` loops over the 
> > begin/end iterators. And technically, you could implement all of those 
> with 
> > `goto`. 
>
> All that sugar exist in many popular languages. decltype(return) does not.
>

My overall point was that your statement "Syntax sugar makes the language 
harder to understand," is wrong.

"many popular languages" don't have typenames that are as large as C++ 
typenames can get. What other languages do or don't do is not by itself 
sufficient justification for what C++ should do or not do.

You can argue that it makes code harder to understand. I don't agree that 
this is sufficient to warrant not having this feature, but you can argue 
it. But arguing that we shouldn't have feature just because other languages 
don't doesn't make sense. We're not making "many popular languages"; we're 
making C++.

Languages are not supposed to be carbon copies of each other.

> That depends on how many lines it takes to enter that return type. After 
> > all, you can use `decltype(return)` even in a function that deduces its 
> > return type from a return statement. So that return type could be quite 
> > lengthy. 
>
> It's already hard to understand what is happening if there's multiple 
> chained functions with auto return type. Adding decltype(return) may 
> make the things wose. 
>
> >> motivates people to write ugly return types instead of providing a 
> >> humanreadable typedef for the result type: 
> > 
> > 
> > You assume that such a typedef can actually be written. Automatic return 
> > type deduction means that types with very complex typenames can be 
> returned. 
> > Not all of them can be easily predicted and culled out with a typedef. 
>
> Could you give an example?
>

A lot of the stuff in Boost.Spirit, for example. What is the return type of 
a complex expression of Spirit parsers?

-- 
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/0cfcac6f-4d8a-40f2-9fc7-cf82c65db117%40isocpp.org.

------=_Part_1044_2021313351.1482851085850
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, December 27, 2016 at 12:43:11 AM UTC-5, Antony=
 Polukhin wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">2016-12-25 22:=
27 GMT+03:00 Nicol Bolas &lt;<a href=3D"javascript:" target=3D"_blank" gdf-=
obfuscated-mailto=3D"LcXw51AvCQAJ" rel=3D"nofollow" onmousedown=3D"this.hre=
f=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascr=
ipt:&#39;;return true;">jmck...@gmail.com</a>&gt;:
<br>&gt;
<br>&gt;
<br>&gt; On Sunday, December 25, 2016 at 2:13:57 PM UTC-5, Antony Polukhin =
wrote:
<br>&gt;&gt;
<br>&gt;&gt; 2016-11-18 19:01 GMT+03:00 Avi Kivity &lt;<a>a...@scylladb.com=
</a>&gt;:
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; map&lt;foo, map&lt;set&lt;bar&gt;, baz&gt;&gt;
<br>&gt;&gt; &gt; complicated(...) {
<br>&gt;&gt; &gt; =C2=A0 =C2=A0 decltype(return) ret;
<br>&gt;&gt; &gt; =C2=A0 =C2=A0 // add stuff to ret
<br>&gt;&gt; &gt; =C2=A0 =C2=A0 return try;
<br>&gt;&gt; &gt; }
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; Instead of repeating the complicated type, refer to it vi=
a
<br>&gt;&gt; &gt; decltype(return).
<br>&gt;&gt; &gt; Won&#39;t work with deduced return types, of course.
<br>&gt;&gt;
<br>&gt;&gt; Syntax sugar makes the language harder to understand.
<br>&gt;
<br>&gt;
<br>&gt; No, it doesn&#39;t. `for` loops are syntactic sugar for `while` lo=
ops.
<br>&gt; Range-based `for` loops are syntactic sugar for `for` loops over t=
he
<br>&gt; begin/end iterators. And technically, you could implement all of t=
hose with
<br>&gt; `goto`.
<br>
<br>All that sugar exist in many popular languages. decltype(return) does n=
ot.<br></blockquote><div><br>My overall point was that your statement &quot=
;Syntax sugar makes the language harder to understand,&quot; is wrong.<br><=
br>&quot;many popular languages&quot; don&#39;t have typenames that are as =
large as C++ typenames can get. What other languages do or don&#39;t do is =
not by itself sufficient justification for what C++ should do or not do.<br=
><br>You can argue that it makes code harder to understand. I don&#39;t agr=
ee that this is sufficient to warrant not having this feature, but you can =
argue it. But arguing that we shouldn&#39;t have feature just because other=
 languages don&#39;t doesn&#39;t make sense. We&#39;re not making &quot;man=
y popular languages&quot;; we&#39;re making C++.<br><br>Languages are not s=
upposed to be carbon copies of each other.<br><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">
&gt; That depends on how many lines it takes to enter that return type. Aft=
er
<br>&gt; all, you can use `decltype(return)` even in a function that deduce=
s its
<br>&gt; return type from a return statement. So that return type could be =
quite
<br>&gt; lengthy.
<br>
<br>It&#39;s already hard to understand what is happening if there&#39;s mu=
ltiple
<br>chained functions with auto return type. Adding decltype(return) may
<br>make the things wose.
<br>
<br>&gt;&gt; motivates people to write ugly return types instead of providi=
ng a
<br>&gt;&gt; humanreadable typedef for the result type:
<br>&gt;
<br>&gt;
<br>&gt; You assume that such a typedef can actually be written. Automatic =
return
<br>&gt; type deduction means that types with very complex typenames can be=
 returned.
<br>&gt; Not all of them can be easily predicted and culled out with a type=
def.
<br>
<br>Could you give an example?<br></blockquote><div><br>A lot of the stuff =
in Boost.Spirit, for example. What is the return type of a complex expressi=
on of Spirit parsers?<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/0cfcac6f-4d8a-40f2-9fc7-cf82c65db117%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0cfcac6f-4d8a-40f2-9fc7-cf82c65db117=
%40isocpp.org</a>.<br />

------=_Part_1044_2021313351.1482851085850--

------=_Part_1043_1940871803.1482851085850--

.
