220 31124 <CAGsORuD5otmjmzVgY7h35uF2PZg1wHRsMzUoHUEddtNuD-p6AA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Zhihao Yuan <zy@miator.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: P0577: No lifetime extension for xvalue .
Date: Fri, 24 Feb 2017 17:00:34 -0600
Lines: 66
Approved: news@gmane.org
Message-ID: <CAGsORuD5otmjmzVgY7h35uF2PZg1wHRsMzUoHUEddtNuD-p6AA@mail.gmail.com>
References: <e1dd36c5-58c4-4f20-870f-d806158b1187@isocpp.org>
 <CAGsORuD=UDBc7MPKcbyH7p4B-EpN8guiw9kOQHHOTmi+=gEqzQ@mail.gmail.com>
 <0f4944b0-11a6-4220-9d48-38086babc97a@isocpp.org> <CAGsORuCo0J-kCzikOHOBk34CrPY=+D_dgF8s1yZKwVgqnHhOUg@mail.gmail.com>
 <2bde698e-c5be-4e20-bca0-d9fa0f90af12@isocpp.org>
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 1487977242 25805 195.159.176.226 (24 Feb 2017 23:00:42 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 24 Feb 2017 23:00:42 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCSKRWMD4EHBBFPWYLCQKGQEMFRDD4I@isocpp.org Sat Feb 25 00:00:37 2017
Return-path: <std-proposals+bncBCSKRWMD4EHBBFPWYLCQKGQEMFRDD4I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f71.google.com ([209.85.218.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCSKRWMD4EHBBFPWYLCQKGQEMFRDD4I@isocpp.org>)
	id 1chOqm-0005yV-5c
	for gclcip-std-proposals@m.gmane.org; Sat, 25 Feb 2017 00:00:32 +0100
Original-Received: by mail-oi0-f71.google.com with SMTP id 62sf12582118oih.5
        for <gclcip-std-proposals@m.gmane.org>; Fri, 24 Feb 2017 15:00:38 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:sender: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:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=QmYW0oIQREPe8gZ5oryy8k/iRdVrIG8sZnz6bO2HE18=;
        b=SDhx+4n1ejTIakmiXP6a3MM3aNI3+/mbr12NQGuEhHCpZv/FB+6KPLjQd5E1YFyF/N
         u93X0EdHYz1H0+IxkX2NjfI/15y/1bdk732f4T+FnMriVILDslSbyLL2Gr3G3uepugJd
         vI9wA9C9KK0lGGympmKac/4SRMG4JUJUCxJ2KjqdxNKsAmYmsFQPimW9RlAAyGhuee39
         YGmffgnbaogycwBuwh50i3B++5e7DF38NMJIhM4uAhgPy3MzCTHCbMHUxShE7cCQSAX3
         r/Zw1pXcPP90YoV3Kiw8YcK9MpKV7HaN7W1cnIne9qBBoDPILUFDVcoaD01qGCgELiBj
         gzmg==
X-Gm-Message-State: AMke39lmKiFGHG8xpvLb/20/rVoUf8w46YkrDbcqx8ASFsfmqozj8wYZv+swmJ1/Za0F9Q==
X-Received: by 10.157.52.218 with SMTP id t26mr1840832otd.63.1487977237790;
        Fri, 24 Feb 2017 15:00:37 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.52.248 with SMTP id t53ls8484071otd.42.gmail; Fri, 24 Feb
 2017 15:00:37 -0800 (PST)
X-Received: by 10.55.190.129 with SMTP id o123mr5699672qkf.110.1487977237068;
        Fri, 24 Feb 2017 15:00:37 -0800 (PST)
Original-Received: from mail-s68.mailgun.info (mail-s68.mailgun.info. [184.173.153.196])
        by mx.google.com with ESMTPS id k66si6619442qkb.260.2017.02.24.15.00.36
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 24 Feb 2017 15:00:36 -0800 (PST)
Received-SPF: pass (google.com: domain of bounce+3f9131.69110-std-proposals=isocpp.org@miator.net designates 184.173.153.196 as permitted sender) client-ip=184.173.153.196;
Original-Sender: zy@miator.net
X-Mailgun-Sending-Ip: 184.173.153.196
X-Mailgun-Sid: WyI3MTBkYiIsICJzdGQtcHJvcG9zYWxzQGlzb2NwcC5vcmciLCAiNjkxMTAiXQ==
Original-Received: from mail-wr0-f174.google.com (mail-wr0-f174.google.com [209.85.128.174])
 by mxa.mailgun.org with ESMTP id 58b0bb14.7fb30425f4b0-smtp-out-n01;
 Fri, 24 Feb 2017 23:00:36 -0000 (UTC)
Original-Received: by mail-wr0-f174.google.com with SMTP id g10so20171492wrg.2
        for <std-proposals@isocpp.org>; Fri, 24 Feb 2017 15:00:36 -0800 (PST)
X-Received: by 10.223.130.114 with SMTP id 105mr4510107wrb.41.1487977235242;
 Fri, 24 Feb 2017 15:00:35 -0800 (PST)
Original-Received: by 10.80.173.212 with HTTP; Fri, 24 Feb 2017 15:00:34 -0800 (PST)
In-Reply-To: <2bde698e-c5be-4e20-bca0-d9fa0f90af12@isocpp.org>
X-Gmail-Original-Message-ID: <CAGsORuD5otmjmzVgY7h35uF2PZg1wHRsMzUoHUEddtNuD-p6AA@mail.gmail.com>
X-Original-Sender: zy@miator.net
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@miator.net;       spf=pass (google.com: domain of
 bounce+3f9131.69110-std-proposals=isocpp.org@miator.net designates
 184.173.153.196 as permitted sender) smtp.mailfrom=bounce+3f9131.69110-std-proposals=isocpp.org@miator.net
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:31124
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31124>

On Fri, Feb 24, 2017 at 4:04 PM, Nicol Bolas <jmckesson@gmail.com> wrote:
> Can you give an example where such code actually makes sense? Where it is
> actually valid and reasonable code, in both the prvalue and xvalue case?

I don't have such code, because my paper hasn't landed :)
Whether it's worth to address, it's question worth to ask
EWG -- maybe next meeting, since I already received
some other comments and I need to address those --
before presenting it.

>
> auto &&x1 = X().s; //This works.
> auto &&x2 = X(); //This works.
>
> auto &&x3 = register X().s; //This works.
> auto &&x4 = register X(); //This doesn't work.

auto&& binds to everything so of course x4 works.

>
> You could use this same reasoning about lots of things we don't allow, like
> casting away `const`-ness with `static_cast`, requiring people to use
> `std::move` in order to move from lvalues, and so forth. Compilers could
> have warned about those things, but we explicitly made them errors.

But you may also noticed that std::move never moves
const and we didn't make that into an error.  Move over,
it copies.  Good or bad, sometimes concerns with
generic programming out weight getting benefits in other
ways -- especially when we are not making the situation
any worse.

>
> It seems to me that having either mechanism alone is overall less effective
> than having both. And your paper doesn't really address this.

Exactly, and that is why.  Neither solely fully works, so
we propose the one which always works, and is forward
compatible with any others.

>
> Also, the idea I suggested is not particularly "smart". It makes no attempt
> to follow variables through to return values and so forth. It only extends
> parameters.

When me and Tim were designing `register` for quite a
while we had a design can do that if I understand what
you are describing correctly -- extending lifetime by
calling a function, right?  And we had a nice explanation
given existing mechanism in the language -- but we
dropped that later.  We believe that we need to do
one thing and do it well.  If we want explicit control,
we don't try to expand the scope.

-- 
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/

-- 
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/CAGsORuD5otmjmzVgY7h35uF2PZg1wHRsMzUoHUEddtNuD-p6AA%40mail.gmail.com.

.
