220 11275 <CABbCQwsB0Zonqx6nve+ARPByTNWV_XC2rCOLOdzuCmxp69nZyA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Maurice Bos <m-ou.se@m-ou.se>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: return type sugar (orthogonal to auto foo() {} )
Date: Thu, 12 Jun 2014 15:49:26 +0200
Lines: 48
Approved: news@gmane.org
Message-ID: <CABbCQwsB0Zonqx6nve+ARPByTNWV_XC2rCOLOdzuCmxp69nZyA@mail.gmail.com>
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: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1402580999 18381 80.91.229.3 (12 Jun 2014 13:49:59 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 12 Jun 2014 13:49:59 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCNPPMPKVYDRB7O742OAKGQEBG35P3I@isocpp.org Thu Jun 12 15:49:54 2014
Return-path: <std-proposals+bncBCNPPMPKVYDRB7O742OAKGQEBG35P3I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f70.google.com ([209.85.215.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCNPPMPKVYDRB7O742OAKGQEBG35P3I@isocpp.org>)
	id 1Wv5O3-00008J-J1
	for gclcip-std-proposals@m.gmane.org; Thu, 12 Jun 2014 15:49:51 +0200
Original-Received: by mail-la0-f70.google.com with SMTP id el20sf866098lab.5
        for <gclcip-std-proposals@m.gmane.org>; Thu, 12 Jun 2014 06:49:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=m-ou.se; s=google;
        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:content-type;
        bh=x762RtIJFvn5nrQDLgnRJ5HV6fLm81Nue5E27sYVuQQ=;
        b=jgh+EjFGACogPff+tk18oRfAX+p+2NgjTcLgW+TfIFX59bcHDXBy5NY02JFAnhzEgY
         GyGvFtDdHFDdoHgv0XziwG8Hf/F3ujQYnRhaXscpJeLRCH25WaiBUdQHe1YqIX+/1lay
         YtLoBp1WpO7tGpxlXC8O3AIsd102binwLu2tk=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=x762RtIJFvn5nrQDLgnRJ5HV6fLm81Nue5E27sYVuQQ=;
        b=lV/hNNRsig15WGqwxRAHiDlh+zAu+S8Ki9PwGrBw3T23fTGSRHyEtCjvwop860lXy6
         X/6UdZyL3D+LSBTKYEeczyMUrmwfweoQTC/cT2fxSZvXMmN6/I68v+D3j/tn0rUVnUq0
         qb2XB5IpMamVfF0Hp5dib/5DDI4Kj5enY8Um5pklFQKATtmlgLtqCXBwOZTymw4NTbVd
         wDPBqB6x9obc4ZH5Ht++wXhAe6Y9WsNuVvCqAY37rjlJM8RFSLIBIQYDqHVbn0l8UNBr
         EnImKHaeH85yffX8shf+5/xCaHnsMuYPc3Z+xZWVRS1fdVcrR+UWXt0jytWZ0+xKJQ9P
         zWVQ==
X-Gm-Message-State: ALoCoQnG4prvu2e2OuYWaAyy2s3t+qRfKmidz9NwXIf4rgA0tYLznUkvmCOPcJShppGIz65hKeEp
X-Received: by 10.194.6.138 with SMTP id b10mr1039211wja.0.1402580991262;
        Thu, 12 Jun 2014 06:49:51 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.43.102 with SMTP id v6ls529046lal.99.gmail; Thu, 12 Jun
 2014 06:49:48 -0700 (PDT)
X-Received: by 10.112.62.231 with SMTP id b7mr1560151lbs.65.1402580988503;
        Thu, 12 Jun 2014 06:49:48 -0700 (PDT)
Original-Received: from mail-la0-x235.google.com (mail-la0-x235.google.com [2a00:1450:4010:c03::235])
        by mx.google.com with ESMTPS id u6si27097457lau.82.2014.06.12.06.49.48
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 12 Jun 2014 06:49:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of m-ou.se@m-ou.se designates 2a00:1450:4010:c03::235 as permitted sender) client-ip=2a00:1450:4010:c03::235;
Original-Received: by mail-la0-f53.google.com with SMTP id ty20so703263lab.40
        for <std-proposals@isocpp.org>; Thu, 12 Jun 2014 06:49:48 -0700 (PDT)
X-Received: by 10.152.6.37 with SMTP id x5mr32643995lax.15.1402580987738;
        Thu, 12 Jun 2014 06:49:47 -0700 (PDT)
Original-Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com [209.85.217.177])
        by mx.google.com with ESMTPSA id n3sm24414218lan.3.2014.06.12.06.49.46
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 12 Jun 2014 06:49:46 -0700 (PDT)
Original-Received: by mail-lb0-f177.google.com with SMTP id u10so687235lbd.8
        for <std-proposals@isocpp.org>; Thu, 12 Jun 2014 06:49:46 -0700 (PDT)
X-Received: by 10.112.76.66 with SMTP id i2mr30936694lbw.37.1402580986195;
 Thu, 12 Jun 2014 06:49:46 -0700 (PDT)
Original-Received: by 10.112.173.72 with HTTP; Thu, 12 Jun 2014 06:49:26 -0700 (PDT)
In-Reply-To: <30a83c0d-00e6-462a-822e-a1789787ec05@isocpp.org>
X-Original-Sender: m-ou.se@m-ou.se
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of m-ou.se@m-ou.se designates 2a00:1450:4010:c03::235 as permitted
 sender) smtp.mail=m-ou.se@m-ou.se;       dkim=pass header.i=@m-ou.se
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:11275
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11275>

decltype(return) sounds good. I wished quite a few times I could've
written this. (D has it in the form of typeof(return):
http://dlang.org/declaration.html#Typeof)

2014-06-12 12:16 GMT+02:00 walter1234 <walter2bz@gmail.com>:
> 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/.

-- 

--- 
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/.

.
