220 11265 <30a83c0d-00e6-462a-822e-a1789787ec05@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: walter1234 <walter2bz@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: return type sugar (orthogonal to auto foo() {} )
Date: Thu, 12 Jun 2014 03:16:04 -0700 (PDT)
Lines: 74
Approved: news@gmane.org
Message-ID: <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_87_22099948.1402568164130"
X-Trace: ger.gmane.org 1402568173 32698 80.91.229.3 (12 Jun 2014 10:16:13 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 12 Jun 2014 10:16:13 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDO7FOW36ILRBZP34WOAKGQEJI7FRPQ@isocpp.org Thu Jun 12 12:16:07 2014
Return-path: <std-proposals+bncBDO7FOW36ILRBZP34WOAKGQEJI7FRPQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qc0-f200.google.com ([209.85.216.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDO7FOW36ILRBZP34WOAKGQEJI7FRPQ@isocpp.org>)
	id 1Wv23C-0008LT-Ug
	for gclcip-std-proposals@m.gmane.org; Thu, 12 Jun 2014 12:16:07 +0200
Original-Received: by mail-qc0-f200.google.com with SMTP id o8sf3950654qcw.7
        for <gclcip-std-proposals@m.gmane.org>; Thu, 12 Jun 2014 03:16:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id: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=mcaXtgSxhZRQmaWMXoOBNmNc8EqI40ftE9/8+NqXwwI=;
        b=ufg6pzwSQgUy0weWeHzvmOdeyEXckGTZNK1UbMdkl07R2TYRoHShi4V8Wsov4dpNeX
         4RUjhWWhuYlwnSkpYAMF2oTJLMeMxxzCbSy4woMzCjuTrbgknUB4/kEm2/sKiRbJUjp/
         /ER6S3RAhxG8pUHqHkREpWDiyunhxnddp7kqHHEPmF9lrnBYelOW1J48c8o5OEzhDzou
         qym5yeNjsp0QnjMMz9yh1CiHbNkf00aOJHTM/HyhRwVvBonqCDD3OmdGLDKhc9OGn3n1
         RIR8NBDumiySvRoq3nKp7SAxjbYMlRMUVpnVa8ohPRro5gGpeEie2ngdrEb/OXgP54XC
         Bsig==
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: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=mcaXtgSxhZRQmaWMXoOBNmNc8EqI40ftE9/8+NqXwwI=;
        b=JlCbRPZESSIKW7+vRA54e0u1HVjTAtbMGN4j03bb+wyyXQO9/vk0/+HTAsRZyA07qU
         03+vptsysE3Zls2yDQVGn6Q3EDYGu35WVZalU8Iit8bj5olVx/Shkdp6P2G2dbsRgaVe
         o8BJ34XLfR7Q/e59ZrCtLKO3FwwICc0K7HzI83jLEZQXVQ8XleP3x4KjCztgreKhN/y/
         i8H0p303V4PynDqF8UtQ5Qqfd9pScFrzl7J7ILZT9nH3Yn7pMbu4pqeNNrt/JS00uI/f
         NqoP9AXo7tQFHCjaOSdBozPXr4TMl1UsTXnxduXCIN8PDCTgwSJtwYxdHvb9EKu+fH37
         Usyw==
X-Gm-Message-State: ALoCoQm02CWZ8MYBtsok2t784f4Tz5Lb40+JhUqcc4EcHxMjwXuc6AcM0YzySSrRF8irzX9pykLq
X-Received: by 10.58.134.36 with SMTP id ph4mr9016907veb.27.1402568165981;
        Thu, 12 Jun 2014 03:16:05 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.131.229 with SMTP id op5ls1648258igb.34.gmail; Thu, 12 Jun
 2014 03:16:05 -0700 (PDT)
X-Received: by 10.50.7.97 with SMTP id i1mr86903iga.8.1402568165289;
        Thu, 12 Jun 2014 03:16:05 -0700 (PDT)
X-Original-Sender: walter2bz@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:11265
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11265>

------=_Part_87_22099948.1402568164130
Content-Type: text/plain; charset=UTF-8

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.

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.

imagine

auto foo(  args...  )->decltype(....some expression based on args...) {

      return_type  accumulator;     // 'return_type' is a shortcut for 
whatever this functions declared return type is..
      ... do stuff with accumulator...

     return accumulator.
}

ways of doing that without a new keyword, perhaps 'decltype(return)' , any 
other ideas..
In some ways this would go beyond what rust currently does. (rust can't yet 
use an expression for the return type, although making it generic often 
works because of how the return types are inferred by callers)

-- 

--- 
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/.

------=_Part_87_22099948.1402568164130
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Coming back to C++ from Rust, one thing begin to miss is t=
he 2way type inference: its a nice choice on their part, you write the type=
s 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 havin=
g sugar to access the declared return type of a function within its own bod=
y.</div><div><br></div><div>imagine</div><div><br></div><div>auto foo( &nbs=
p;args... &nbsp;)-&gt;decltype(....some expression based on args...) {</div=
><div><br></div><div>&nbsp; &nbsp; &nbsp; return_type &nbsp;accumulator; &n=
bsp; &nbsp; // 'return_type' is a shortcut for whatever this functions decl=
ared return type is..</div><div>&nbsp; &nbsp; &nbsp; ... do stuff with accu=
mulator...</div><div><br></div><div>&nbsp; &nbsp; &nbsp;return accumulator.=
</div><div>}</div><div><br></div><div>ways of doing that without a new keyw=
ord, perhaps 'decltype(return)' , any other ideas..</div><div>In some ways =
this would go beyond what rust currently does. (rust can't yet use an expre=
ssion for the return type, although making it generic often works because o=
f how the return types are inferred by callers)</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_87_22099948.1402568164130--

.
