220 11298 <1cf79c47-8a07-4e41-b96b-465b01e044fa@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: return type sugar (orthogonal to auto foo() {} )
Date: Fri, 13 Jun 2014 09:24:27 -0700 (PDT)
Lines: 107
Approved: news@gmane.org
Message-ID: <1cf79c47-8a07-4e41-b96b-465b01e044fa@isocpp.org>
References: <30a83c0d-00e6-462a-822e-a1789787ec05@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_317_24531460.1402676667554"
X-Trace: ger.gmane.org 1402676683 21591 80.91.229.3 (13 Jun 2014 16:24:43 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 13 Jun 2014 16:24:43 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDT2DGOJ34DBBPOL5SOAKGQE6Q3WLBY@isocpp.org Fri Jun 13 18:24:36 2014
Return-path: <std-proposals+bncBDT2DGOJ34DBBPOL5SOAKGQE6Q3WLBY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f197.google.com ([209.85.220.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDT2DGOJ34DBBPOL5SOAKGQE6Q3WLBY@isocpp.org>)
	id 1WvUHH-0006pi-Gv
	for gclcip-std-proposals@m.gmane.org; Fri, 13 Jun 2014 18:24:31 +0200
Original-Received: by mail-vc0-f197.google.com with SMTP id il7sf8320010vcb.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 13 Jun 2014 09:24:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=1zOX9yPoF+2HZpqK6MIH+/PXRsbN5do6/PpWEHqP4fY=;
        b=S8haiG0QKZFAj+j5ts2D26v19OtiGPv60RfuowaVGFPzdUbFidXcIcBWKX/2c/vk2J
         pT6xIXkKlBM206tMisyZokvJc+2yOG+3l1b8+iEv2qQLGPUbkwTz7OoA7yDfS56O6NGk
         CVZGMYPLfYuvyCMpWJ8tFwoY+r/IBA/t6HRuVXCyeis5wpkIQ9bYS7xOMfNn5GYT1Yoe
         VbFyTBzQV4Ad6kz4tfBUC5j+id7tm/PpmMOMtZT1aNkN2y8CWRaTtZyRGmL8AX98uXuP
         XKzvyoUoc6QfK3iWcbMMW45e8xFJ32rYobSYgcndJfcxMqzVi5Bh++X0+CSJzxhl73Yf
         kOLQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=1zOX9yPoF+2HZpqK6MIH+/PXRsbN5do6/PpWEHqP4fY=;
        b=H+J1ctG9OimCnPUdklqSXuXBJBnoe+4qqJ3hQ4e+3SDOW7N8ckq2fy6+Dj8gukr7Z9
         1chxnK7rqCaCCJMDx+zs1nC4ru3sQ0+bsW2E8oEqSZPMJSyYskeZAIlRRhEHsJDX2UbV
         sAwG3bBWhbvXSxD9OsdvSK/BpTzGC0acl1weZ0xKCxK5gS4dbBif0/orw0S+tTL8EEdg
         TXgk937NIe3tcT9yiSvIf2Bn0Ks/OGfKQ8yLNRAWmeHw0agQKOWPRZN3YCL448A7bkpR
         0jNF6d0aSld1t2YPra3cCm62Q9iERo6a4aCG4t1EufOvupBBF02GtXfGJQj18EJWPq7/
         +zuQ==
X-Gm-Message-State: ALoCoQl+nBzpYU78nsHBFX6iEs++cVI/u37SNBoZ7LokLojJ728zXThopRJWTZydTC0JYZPPy7jY
X-Received: by 10.58.182.137 with SMTP id ee9mr996130vec.37.1402676670452;
        Fri, 13 Jun 2014 09:24:30 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.128.110 with SMTP id nn14ls301296igb.1.gmail; Fri, 13 Jun
 2014 09:24:28 -0700 (PDT)
X-Received: by 10.50.17.100 with SMTP id n4mr105598igd.3.1402676668941;
        Fri, 13 Jun 2014 09:24:28 -0700 (PDT)
In-Reply-To: <30a83c0d-00e6-462a-822e-a1789787ec05@isocpp.org>
X-Original-Sender: akrzemi1@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: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:11298
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11298>

------=_Part_317_24531460.1402676667554
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


W dniu czwartek, 12 czerwca 2014 12:16:04 UTC+2 u=C5=BCytkownik walter1234=
=20
napisa=C5=82:
>
> Coming back to C++ from Rust, one thing begin to miss is the 2way type=20
> inference: its a nice choice on their part, you write the types in the=20
> signature, then the types in the body are inferred.
>
> But perhaps a significant amount of this use could be covered by having=
=20
> sugar to access the declared return type of a function within its own bod=
y.
>
> imagine
>
> auto foo(  args...  )->decltype(....some expression based on args...) {
>
>       return_type  accumulator;     // 'return_type' is a shortcut for=20
> whatever this functions declared return type is..
>       ... do stuff with accumulator...
>
>      return accumulator.
> }
>
> ways of doing that without a new keyword, perhaps 'decltype(return)' , an=
y=20
> other ideas..
> In some ways this would go beyond what rust currently does. (rust can't=
=20
> yet use an expression for the return type, although making it generic oft=
en=20
> works because of how the return types are inferred by callers)
>
=20
How about doing it the Go style:
=20
auto foo(  args...  ) -> decltype(....some expression based on args...)=20
accumulator
{  =20
  do_stuff_with(accumulator);
  return accumulator.
}
=20

--=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/.

------=_Part_317_24531460.1402676667554
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br>W dniu czwartek, 12 czerwca 2014 12:16:04 UTC+2 u=C5=
=BCytkownik walter1234 napisa=C5=82:<blockquote style=3D"margin: 0px 0px 0p=
x 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-l=
eft-width: 1px; border-left-style: solid;" class=3D"gmail_quote"><div dir=
=3D"ltr">Coming back to C++ from Rust, one thing begin to miss is the 2way =
type inference: its a nice choice on their part, you write the types in the=
 signature, then the types in the body are inferred.<div><br></div><div>But=
 perhaps a significant amount of this use could be covered by having sugar =
to access the declared return type of a function within its own body.</div>=
<div><br></div><div>imagine</div><div><br></div><div>auto foo( &nbsp;args..=
.. &nbsp;)-&gt;decltype(....some expression based on args...) {</div><div><b=
r></div><div>&nbsp; &nbsp; &nbsp; return_type &nbsp;accumulator; &nbsp; &nb=
sp; // 'return_type' is a shortcut for whatever this functions declared ret=
urn type is..</div><div>&nbsp; &nbsp; &nbsp; ... do stuff with accumulator.=
...</div><div><br></div><div>&nbsp; &nbsp; &nbsp;return accumulator.</div><d=
iv>}</div><div><br></div><div>ways of doing that without a new keyword, per=
haps 'decltype(return)' , any other ideas..</div><div>In some ways this wou=
ld go beyond what rust currently does. (rust can't yet use an expression fo=
r the return type, although making it generic often works because of how th=
e return types are inferred by callers)</div></div></blockquote><div>&nbsp;=
</div><div>How about doing it the Go style:</div><div>&nbsp;</div><div>auto=
 foo(&nbsp; args...&nbsp; ) -&gt; decltype(....some expression based on arg=
s...) accumulator<br>{&nbsp;&nbsp;&nbsp;<br>&nbsp; do_stuff_with(accumulato=
r);<br>&nbsp; return accumulator.<br>}</div><div>&nbsp;</div></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_317_24531460.1402676667554--

.
