220 36011 <p1b413$55t$1@blaine.gmane.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: David Brown <david@westcontrol.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: auto return proposal
Date: Tue, 19 Dec 2017 14:27:58 +0100
Lines: 58
Approved: news@gmane.org
Message-ID: <p1b413$55t$1@blaine.gmane.org>
References: <CAB+4KHJCie_iwSm5OQVaHfsutdVJVbBo3ALecvn1ibsKg4uDTQ@mail.gmail.com> <7a3b438a-ec7f-4827-a24c-5466fe57410c@isocpp.org> <CADtNNhjciHtmn2vS9OTzPsFkyPDsGhTqS_132pJg6eDEFoSA_w@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1513689974 10672 195.159.176.226 (19 Dec 2017 13:26:14 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 19 Dec 2017 13:26:14 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDP6R2XHXIARB25H4TIQKGQENOYJS2Y@isocpp.org Tue Dec 19 14:26:10 2017
Return-path: <std-proposals+bncBDP6R2XHXIARB25H4TIQKGQENOYJS2Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f70.google.com ([209.85.215.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDP6R2XHXIARB25H4TIQKGQENOYJS2Y@isocpp.org>)
	id 1eRHuM-0002Pb-7c
	for gclcip-std-proposals@m.gmane.org; Tue, 19 Dec 2017 14:26:10 +0100
Original-Received: by mail-lf0-f70.google.com with SMTP id m35sf4426338lfi.9
        for <gclcip-std-proposals@m.gmane.org>; Tue, 19 Dec 2017 05:28:12 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1513690092; cv=pass;
        d=google.com; s=arc-20160816;
        b=nTEHznMNhP0cARMzmrPizjQByufAR/1km5YTOSB0Fk50/WyoxWrz4fBcmqy3LahQ+v
         P3dFznxxnZxByJxc4a5+1ga2eGreVD+LasBnQH+ZdrQgTV4Rv+tEHBm/BSnG6mFtQnd7
         gxioJrxIswL35M8Fj3ShPRTkXpPdjyHfGiBnn1WIJuUcKaA84v3808FOv+GNpAKWtOkn
         WoR3+pJ32UHDTrSpJ/4iXSYtx8O22e87mLxB2iU6R8P/XmzzFsNJClkJ6dE3mfs2PDyk
         TAJi+u9rzVfFXNw/EwT0qrE0hm+HdIZyAWhNlZqKhN58gWjgzFVljZt+xYRznvJ/7hu9
         lITQ==
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:in-reply-to:user-agent
         :mime-version:references:message-id:lines:date:subject:from:to
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=UVksho4ud0D6ONqw6AVkuju2yf7yqpOp0hjapBtjLvs=;
        b=G81xixPzSkmJFWwQ1OEp//qiimz0b8JPE5p3bV/tGUabO+Hxw+OU5OQOWXyUptwIz+
         y+/53BU9t7TLqk5j/QcBRyKhWV2LC4QXmp9/YVIkDdDZnNeIRgy4xtuKF+nqr60lR18p
         D+ZzSw+MQkR/gs4yuB9AhxqleH8bpmboGyC8Ddc4v/RAaVB5z4oagiJGKfCJEQ4ak7CP
         pgnaVDNrLibjhK+1x/WA+cmSktYBFRzTvD+zyuM09oRxWXHWrHDb6b0rt4ufxH92UrQE
         VuL5BiT74fr1xVp5TWeeWJp1wO1SXo2pYZOddIY8InD2BxqZbt3cxdWACxd/3KjRC8gl
         ybmw==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=neutral (google.com: 195.159.176.226 is neither permitted nor denied by best guess record for domain of gclcip-std-proposals@m.gmane.org) smtp.mailfrom=gclcip-std-proposals@m.gmane.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=to:from:subject:date:lines:message-id:references:mime-version
         :user-agent:in-reply-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=UVksho4ud0D6ONqw6AVkuju2yf7yqpOp0hjapBtjLvs=;
        b=N7bbeA5aGdWh2XyVU2qLwgePRGhBbzTGQeMM8iz00/v/0XYMYwfbsGMaAYt6CIExlD
         WAqbDDMJc+6fD3e3Cz/fTJyAEoKoksijA4VM01IpPQw3DLAwaCIFj6eSYUURp6O7nCaP
         qqR3c402T2rx1F6jahAFGVXQdL0tD2lc6IkqY3izJv3FY/ttuQpogj3lBNkTIfe4ZT7g
         lIzBoXvE8FwY4y83yeDRnSoZUyXLjlMjaLc1HDnpOzFfPh808n4qk8Ih8vTqFe1Pxujn
         1KFTsaa2T4IPhyLRolknGYfX4vf3hMHGQ9rAocwZG+WLgOCAPQfO69wvvubZlp8TY00q
         wWsA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:to:from:subject:date:lines:message-id:references
         :mime-version:user-agent:in-reply-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=UVksho4ud0D6ONqw6AVkuju2yf7yqpOp0hjapBtjLvs=;
        b=oYt7i4Qky118CIxJI8wh1m4V8Fy/sxTy0g6KPUKN/u59aA/PmoFhW3wAFlLes5uZzt
         Gte+csyQBmmDsig0SILvcETja7N9JfQAsFQ0eero6ifpDK3HxLTJF31mqjQLf/mZKp0r
         M5g4dXUHRJUF31tsK6nhRrPfqhkXcljOvpJ6AM7k1sefpzPxtNcQ4te+gD9Klfgqt25T
         XBLbhfvNRqxEp1cDvlXimb+dNLqpBLMnTorJqTzXCPotoqtVtYqqkPwsXHBvE8P9w+5f
         d5zSBOUz4oK8EvUH5AGHPveqhdO/OMvc96PLYkbJIjcB+kMONMVPUSSqAIVIWJCyU+nW
         YqFg==
X-Gm-Message-State: AKGB3mLtg13z/8P03kM7HSWYNOiLEB/lres6j3j0AUh9Le8IjobL/8SV
	eCJoIPxaSyzoLQGsxFAfmA0=
X-Google-Smtp-Source: ACJfBoue/z9XyW3VkOHrsurOOxta3XbXqosUtwoAalzB8Wq0KTyZ+Jo1hOg/bUBcKjlCmZj1p+IrQg==
X-Received: by 10.46.42.6 with SMTP id q6mr241098ljq.21.1513690092688;
        Tue, 19 Dec 2017 05:28:12 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.46.67.136 with SMTP id z8ls2372640lje.2.gmail; Tue, 19 Dec
 2017 05:28:11 -0800 (PST)
X-Received: by 10.46.29.13 with SMTP id d13mr2341615ljd.8.1513690090995;
        Tue, 19 Dec 2017 05:28:10 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1513690090; cv=none;
        d=google.com; s=arc-20160816;
        b=A+E3ZTCqhnVvJn+l1emY5zxXg3eDCJ+QDUMAZthoFnq9oPJVDIbRMDQ+6z4QJpgn1a
         FbqnhzsLQzm2eCnW3V4MmgyQDNvewy6y3hb8kHOTZ38FD8tuuMT3tTeBvkY1xUIeKKwj
         8WmgOD37KNCGjeZi02ehE2Z/xTkc1uVfholcmtvYHq557QMYlQHHGZ0w1cjKZmYhroxX
         fDQ51GV/wpDWT/E6/Xzac8n6IXLkoO6kLXSnk2iH+FKzuS01edMbSHYvIo1ltPKvfUaf
         Uv8QV52lJWaa1QMJihZ9DlgSy3svQ+epV50dxU2nsVqER5tFkfPM7AYrSBJqEBeKUv/e
         0b+A==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=in-reply-to:user-agent:content-transfer-encoding:mime-version
         :references:message-id:lines:date:subject:from:to
         :arc-authentication-results;
        bh=wLyd2rMDfU0VXBMjkl4zMPPuHdzR01pVnkqt8YWtgQM=;
        b=SavRkJIpa74CANRCcHB21Xci956dRu7eFTzktdQHmkuPKdyyCn3Rpzyi9+CkTaKWiu
         hY8H9P3ItJ6PI0966OpJib9ejLbs3pmnVJklmHuF+oQXdwLhkuUqQ+PpwdSqn7uA/qZp
         8AcGeYC2lUMHawkxw+piMaPj/IdhZ5DBXrCelFOPkbBB4g2YTqfnYdkqU6S3FgHw6NtF
         hdD34O7Pj+6VTNWr0jdyFZdkcktaukJ2HeMeh/zpn9eHnURsdLlcqXl4ivMBsy9S59sW
         /5FghXfh+k09v4ToMmCJHQmLTQ9f7B+iILSr/PIzYL7gRlHQgpAounoHgM+xDoS9Hx4E
         yo2Q==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: 195.159.176.226 is neither permitted nor denied by best guess record for domain of gclcip-std-proposals@m.gmane.org) smtp.mailfrom=gclcip-std-proposals@m.gmane.org
Original-Received: from blaine.gmane.org ([195.159.176.226])
        by mx.google.com with ESMTPS id i123si5604965lji.372.2017.12.19.05.28.10
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 19 Dec 2017 05:28:10 -0800 (PST)
Received-SPF: neutral (google.com: 195.159.176.226 is neither permitted nor denied by best guess record for domain of gclcip-std-proposals@m.gmane.org) client-ip=195.159.176.226;
Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2)
	(envelope-from <gclcip-std-proposals@m.gmane.org>)
	id 1eRHuI-00026P-4j
	for std-proposals@isocpp.org; Tue, 19 Dec 2017 14:26:06 +0100
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 51
Original-X-Complaints-To: usenet@blaine.gmane.org
In-Reply-To: <CADtNNhjciHtmn2vS9OTzPsFkyPDsGhTqS_132pJg6eDEFoSA_w@mail.gmail.com>
X-Original-Sender: david@westcontrol.com
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 195.159.176.226 is neither permitted nor denied by best guess
 record for domain of gclcip-std-proposals@m.gmane.org) smtp.mailfrom=gclcip-std-proposals@m.gmane.org
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:36011
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36011>

On 19/12/17 13:54, Jan Wilmans wrote:
>     Semi-serious proposal: allow inference of auto variable types from
>     any use not just initialization:
> 
>       void foo(int& out);
>      
>       double bar() {
>       auto i; // i is int
>       auto j; //j is string
>       auto r; // r is double
>       foo(i);
>       j = "hello"s;
>       ...
>       return r;
>     }
> 
>     Semi-serious because full Hindley-Milner  (or variants) inference is
>     probably not workable in C++, but some restricted variant still might.
> 
> 
> Please provide a rationale why such a terrible looking idea would be
> good? I think this would promote uninitialised variables, so effectively
> drain auto of one of its best qualities.
> 
> 

I would say it could be useful in cases like this:

auto number(int x) {
	auto s;
	if (x == 0) {
		s = "zero"s;
	} else if (x == 1) {
		s = "one"s;
	} else {
		s = "not a nice number"s;
	}
	return s;
}

i.e., you don't have a suitable initial value to use.

But you can eliminated cases where you have a simple constructor that
the compiler can optimise away, cases that are easily expressed with
conditional operator, cases where you could return the result directly
without using a local variable, and cases where it's not particularly
hard to give the type directly.  I don't think the remaining use-cases
are enough to warrant such a feature in the language.




-- 
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/p1b413%2455t%241%40blaine.gmane.org.

.
