220 25476 <4f31b957-05be-47cf-a1ca-03f33a9900c0@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: isocppgroup@denisbider.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Relocation as a solution for the valueless
 variant problem?
Date: Thu, 7 Apr 2016 21:38:14 -0700 (PDT)
Lines: 235
Approved: news@gmane.org
Message-ID: <4f31b957-05be-47cf-a1ca-03f33a9900c0@isocpp.org>
References: <b4feb52d-4cd0-475f-9f3d-6694564bc1b0@isocpp.org>
 <4187538d-68fa-4582-ba26-f406479abe67@isocpp.org>
 <eafd831f-85d2-430c-9969-7d084e6d28d2@isocpp.org>
 <CALQmNFggBQSADjEqS7pEzcdPSStGJfXkJdX0d2CwW_TmwqA=yQ@mail.gmail.com>
 <105d82bc-e1cf-4795-894c-112cd591c3af@isocpp.org>
 <CALQmNFja3Kt1XRR8S7Qr3rOktChVzuDGO7ZtSaQpsWaohU6wAA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_130_2079848649.1460090294215"
X-Trace: ger.gmane.org 1460090299 15757 80.91.229.3 (8 Apr 2016 04:38:19 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 8 Apr 2016 04:38:19 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD5LNK7YQYJRBN7LTS4AKGQENLGZNZA@isocpp.org Fri Apr 08 06:38:18 2016
Return-path: <std-proposals+bncBD5LNK7YQYJRBN7LTS4AKGQENLGZNZA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f69.google.com ([209.85.218.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5LNK7YQYJRBN7LTS4AKGQENLGZNZA@isocpp.org>)
	id 1aoOBV-0004ly-V1
	for gclcip-std-proposals@m.gmane.org; Fri, 08 Apr 2016 06:38:18 +0200
Original-Received: by mail-oi0-f69.google.com with SMTP id v67sf139937622oie.0
        for <gclcip-std-proposals@m.gmane.org>; Thu, 07 Apr 2016 21:38:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=hGSzKo+79LCi2N/xtPal1bKmWRuy5aXKLp5OtjIcBjo=;
        b=0w9WH67QTUuVM4Oa0YkZNuJuZ5bNCxaOVMwSSTgy2DsKUVkqLjSy1ynP+cOCllj2Ot
         j3l+gSznxcnC3vslnPShW04SlDGiaOp8g3m9N+ik3HUdGPAVWNNCPI84q0PkbHokYpJK
         0JVtDFf1cTe+OvtIW+LXwcOpSo/HHUCMqoB16A2+Ixowj6R8eSAWry5BE8ekmbmt+l7l
         OU2CtV6+7mptUedMsxFwH2U/bZNTL3ukHnJA3rKVH3JH+gyP2DwQyF5P0GPUW1zo4/nr
         BTLmQVcQPTwlcNVelPYyo7lLP0dl0v2zMlcJG+l4rHsHgjoa/pNSzRXKpryC/mfdg4zF
         z2Bw==
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:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=hGSzKo+79LCi2N/xtPal1bKmWRuy5aXKLp5OtjIcBjo=;
        b=GNy5YbR2a6hGGj1l8NesZTaffHGgwNVxSmm62dFBrTfspCuYCkFy3p17JnpRk8OMzu
         rAekBZE9CkfRsiN06GZX0za+hFxWqgL47nLgPgKwPzCzPkyJ0hdT+qvjp/oAB2az2QW8
         sDt7znOijm8V3A3MyIuFxPGDaE1nClyweP0GHWE3QlPupGyCZmHPSIOUNWTF9kOuCbIj
         0Lahs9ERKc9MG+FMmdKKTfbn93i+dkgVyBdqBkxmxqYyOgzlwyck2EHZPnspIrtSlxw8
         bJDc6g3uauY5XBKW4+X3V4n/iwC05zTnxUzNkdBFPJTlu+fU3ZjRq7igU7WPfiIENRZQ
         m5PQ==
X-Gm-Message-State: AD7BkJI1XHH9cgDk+/ENw8IyUlUqteW6LFLtao5DxUN1VMJguNPN/b4abpNmXcuc+giMig==
X-Received: by 10.157.15.9 with SMTP id 9mr4385571ott.28.1460090296814;
        Thu, 07 Apr 2016 21:38:16 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.3.12 with SMTP id 12ls1089423iod.2.gmail; Thu, 07 Apr 2016
 21:38:15 -0700 (PDT)
X-Received: by 10.50.86.134 with SMTP id p6mr20849igz.9.1460090295478;
        Thu, 07 Apr 2016 21:38:15 -0700 (PDT)
In-Reply-To: <CALQmNFja3Kt1XRR8S7Qr3rOktChVzuDGO7ZtSaQpsWaohU6wAA@mail.gmail.com>
X-Original-Sender: isocppgroup@denisbider.com
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:25476
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/25476>

------=_Part_130_2079848649.1460090294215
Content-Type: multipart/alternative; 
	boundary="----=_Part_131_229753461.1460090294215"

------=_Part_131_229753461.1460090294215
Content-Type: text/plain; charset=UTF-8

Hey Sean,

if you would like to see move destruction / relocation proposed in a safer 
form, do you have any ideas about what that safer form would look like?

You refer to that modern C++ discourages direct use of new and delete. 
Well, yes, of course. But libraries still need to use new and delete, as 
well as placement new, to implement containers. How would you propose 
implementing the standard library without these features?

It is not the intention of this Relocator proposal to be used directly by 
end users. The intention is that it would be used in STL implementations, 
to solve problems that a lack of destructive move makes difficult.

Language users should not have to worry about invoking or implementing 
relocators, in much the same way they shouldn't have to worry about move 
constructors. Language users should use standard library types, and it's up 
to the library types to implement relocators and move constructors.

If you have any ideas of how the proposed feature can be made safer, I 
would love to hear about it.

However, this is not to be mistaken for a feature that end users should 
directly use.


On Wednesday, April 6, 2016 at 10:45:09 PM UTC-6, Sean Middleditch wrote:

>
> On Apr 6, 2016 9:55 AM, <isocp...@denisbider.com <javascript:>> wrote:
> >
> > > The committee can mandate that standard library types all have
> > > relocators added where necessary but it can do no such thing for
> > > user types. However, the committee _does_ want to allow variant
> > > to be used with those same problematic user types.
> >
> >
> > With respect to variant, it is already a major advantage of relocation 
> that it can support:
> >
> > - exception-safe use of variant with non-nullable standard library types 
> - without requiring an existing std::list implementation to be thrown away 
> so it can be nothrow_move_constructible;
> >
> > - exception-safe use of variant with future non-nullable types.
>
> But not "exception safe" for other types, meaning that it still requires 
> the work around with the valueless state. So we go from a "mostly never 
> empty" container to a "slightly more mostly never empty" container. :)
>
> >
> >
> > Existing problematic non-library types can of course still be supported, 
> if we're willing to lose the strong exception safety guarantee in that 
> case. I'm not sure there is a silver bullet that can avoid that.
> >
> >
> > > With your proposal, it's way too easy to accidentally leave
> > > some object in an undefined state
> >
> > I find this logic highly questionable. By this line of reasoning, we 
> should remove placement new, C-style casts, and manual memory management, 
> so that C++ might become a managed language.
>
> Not at all, and that's quite the logical jump. For one, your feature 
> doesn't actually exist yet, while those others do; adding unsafe features 
> and keeping old unsafe features (that we actually _do_ kinda-sorta 
> deprecate, e.g. the modern advice to never ever use new/delete or C-style 
> casts) for back-compat are two very different things. :)
>
> For two, there are degrees of ease-of- misuse and not just a binary 
> equation of assembly vs C# :)  Rust for instance is a case of going too far 
> with protecting users from mistakes and going straight into forcing users 
> to jump through hoops to convince the compiler of the validity of perfectly 
> valid code. It errs completely on the side of safety. Nobody is (seriously) 
> advocating that for C++. Neither should we be advocating to adding more 
> C-level-dangerous constructs to C++ without darn good reason. Half-fixing 
> variant and not actually fixing many _other_ major problems that 
> destructive move could solve (e.g., accidentally using a moved-from 
> parameter instead of the moved-to member in a class constructor).
>
> For three, your feature proposal opens whole new classes of mistakes than 
> what we have today. The only mechanism even close to being as dangerous is 
> delete/free and modern C++ all but deprecates those features in user code, 
> even in high-performance situations like AAA games. A "good" destructive 
> move should _reduce_ errors in existing code -- like accidentally using 
> moved-from values -- rather than adding new ones. Performance alone isn't 
> good enough. Remember, rvalue references _real_ goal was to allow us to 
> replace things like the easy-to-misuse auto_ptr with the much superior 
> unique_ptr. The potential performance improvements of move semantics were 
> icing on the cake.
>
> Now let's be clear: the intent of relocation is good. We need someone 
> working on this, IMO. I'm more than happy to see you work on it; you seem 
> like a pretty bright person and are obviously passionate about the issue. I 
> just strongly think that the proposal you currently have just isn't "there" 
> yet and needs more design iteration. :)
>
> >
>

-- 
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/4f31b957-05be-47cf-a1ca-03f33a9900c0%40isocpp.org.

------=_Part_131_229753461.1460090294215
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hey Sean,</div><div><br></div><div>if you=C2=A0would =
like to see=C2=A0move destruction / relocation proposed in a safer form, do=
 you have any ideas about what that safer form would look like?</div><div><=
br></div><div>You refer to that modern C++ discourages direct use of new an=
d delete. Well, yes, of course. But libraries still need to use new and del=
ete,=C2=A0as well as=C2=A0placement new,=C2=A0to implement containers. How =
would you propose implementing the standard library without these features?=
</div><div><br></div><div>It is not the intention of this Relocator proposa=
l to be used directly by end users. The intention is that it would be used =
in STL implementations, to solve problems that a lack of destructive move m=
akes difficult.</div><div><br></div><div>Language users should not have to =
worry about invoking or implementing relocators, in much the same way they =
shouldn&#39;t have to worry about move constructors. Language users should =
use standard library types, and it&#39;s up to the library types to impleme=
nt relocators and move constructors.</div><div><br></div><div>If you have a=
ny ideas of how=C2=A0the proposed feature=C2=A0can be made safer, I would l=
ove to hear about it.</div><div><br></div><div>However, this is not to be m=
istaken for a feature that end users should directly use.</div><div><br><br=
>On Wednesday, April 6, 2016 at 10:45:09 PM UTC-6, Sean Middleditch wrote:<=
/div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; =
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width=
: 1px; border-left-style: solid;"><div dir=3D"ltr"><p dir=3D"ltr"><br>
On Apr 6, 2016 9:55 AM, &lt;<a onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;" href=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-m=
ailto=3D"VosGVw0oAgAJ">isocp...@denisbider.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; The committee can mandate that standard library types all have<br=
>
&gt; &gt; relocators added where necessary but it can do no such thing for<=
br>
&gt; &gt; user types. However, the committee _does_ want to allow variant<b=
r>
&gt; &gt; to be used with those same problematic user types.<br>
&gt;<br>
&gt;<br>
&gt; With respect to variant, it is already a major advantage of relocation=
 that it can support:<br>
&gt;<br>
&gt; - exception-safe use of variant with non-nullable standard library typ=
es - without requiring an existing std::list implementation to be thrown aw=
ay so it can be nothrow_move_constructible;<br>
&gt;<br>
&gt; - exception-safe use of variant with future non-nullable types.</p><p>=
But not &quot;exception safe&quot; for other types, meaning that it still r=
equires the work around with the valueless state. So we go from a &quot;mos=
tly never empty&quot; container to a &quot;slightly more mostly never empty=
&quot; container. :)</p><p dir=3D"ltr">
&gt;<br>
&gt;<br>
&gt; Existing problematic non-library types can of course still be supporte=
d, if we&#39;re willing to lose the strong exception safety guarantee in th=
at case. I&#39;m not sure there is a silver bullet that can avoid that.<br>
&gt;<br>
&gt;<br>
&gt; &gt; With your proposal, it&#39;s way too easy to accidentally leave<b=
r>
&gt; &gt; some object in an undefined state<br>
&gt;<br>
&gt; I find this logic highly questionable. By this line of reasoning, we s=
hould remove placement new, C-style casts, and manual memory management, so=
 that C++ might become a managed language.</p>
<p dir=3D"ltr">Not at all, and that&#39;s quite the logical jump. For one, =
your feature doesn&#39;t actually exist yet, while those others do; adding =
unsafe features and keeping old unsafe features (that we actually _do_ kind=
a-sorta deprecate, e.g. the modern advice to never ever use new/delete or C=
-style casts) for back-compat are two very different things. :)</p>
<p dir=3D"ltr">For two, there are degrees of ease-of- misuse and not just a=
 binary equation of assembly vs C# :) =C2=A0Rust for instance is a case of =
going too far with protecting users from mistakes and going straight into f=
orcing users to jump through hoops to convince the compiler of the validity=
 of perfectly valid code. It errs completely on the side of safety. Nobody =
is (seriously) advocating that for C++. Neither should we be advocating to =
adding more C-level-dangerous constructs to C++ without darn good reason. H=
alf-fixing variant and not actually fixing many _other_ major problems that=
 destructive move could solve (e.g., accidentally using a moved-from parame=
ter instead of the moved-to member in a class constructor).</p>
<p dir=3D"ltr">For three, your feature proposal opens whole new classes of =
mistakes than what we have today. The only mechanism even close to being as=
 dangerous is delete/free and modern C++ all but deprecates those features =
in user code, even in high-performance situations like AAA games. A &quot;g=
ood&quot; destructive move should _reduce_ errors in existing code -- like =
accidentally using moved-from values -- rather than adding new ones. Perfor=
mance alone isn&#39;t good enough. Remember, rvalue references _real_ goal =
was to allow us to replace things like the easy-to-misuse auto_ptr with the=
 much superior unique_ptr. The potential performance improvements of move s=
emantics were icing on the cake.</p>
<p dir=3D"ltr">Now let&#39;s be clear: the intent of relocation is good. We=
 need someone working on this, IMO. I&#39;m more than happy to see you work=
 on it; you seem like a pretty bright person and are obviously passionate a=
bout the issue. I just strongly think that the proposal you currently have =
just isn&#39;t &quot;there&quot; yet and needs more design iteration. :)</p=
>
<p dir=3D"ltr">&gt;<br>
</p>
</div>
</blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4f31b957-05be-47cf-a1ca-03f33a9900c0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4f31b957-05be-47cf-a1ca-03f33a9900c0=
%40isocpp.org</a>.<br />

------=_Part_131_229753461.1460090294215--
------=_Part_130_2079848649.1460090294215--

.
