220 11589 <29988A30-548A-47F3-A275-9B6099329877@gmail.com> article
Path: news.gmane.org!not-for-mail
From: David Krauss <potswa@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Teachability problems with std::move
Date: Sat, 28 Jun 2014 06:30:17 +0800
Lines: 171
Approved: news@gmane.org
Message-ID: <29988A30-548A-47F3-A275-9B6099329877@gmail.com>
References: <CA+cyFgsYFbjG1M98PJS-XVzuJYbQmt7=4GOqS5_V5-WVJ0caLg@mail.gmail.com> <FC52D786-962E-4525-8997-E5C764AE5780@gmail.com> <CA+cyFgtNWh2sVd7ajaf+HwfLM2BiYGWjXEUVhOp84kpoVfrDkQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_86B416BA-23C9-4A36-A216-1EA192BC5B5E"
X-Trace: ger.gmane.org 1403908219 31395 80.91.229.3 (27 Jun 2014 22:30:19 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 27 Jun 2014 22:30:19 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRB4XAW6OQKGQENKSBZAQ@isocpp.org Sat Jun 28 00:30:13 2014
Return-path: <std-proposals+bncBCW25A7E3QCRB4XAW6OQKGQENKSBZAQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pd0-f198.google.com ([209.85.192.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRB4XAW6OQKGQENKSBZAQ@isocpp.org>)
	id 1X0eeq-0005JR-1Q
	for gclcip-std-proposals@m.gmane.org; Sat, 28 Jun 2014 00:30:12 +0200
Original-Received: by mail-pd0-f198.google.com with SMTP id y10sf20527063pdj.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 27 Jun 2014 15:30:10 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:mime-version:subject:date
         :references:to: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:content-type;
        bh=fPkieLv5V28BqQOMMPkqaY2UJFoBmu7ASQNX1XX1E9M=;
        b=PLl7/1bvjeL3jOusxtDVHXrLldkL00gfjh+mAqbNKRpn8qJ27DH7ECSlil/LxrSl6l
         KvoZNFKWYxIodIsZ3X76uQ4BiYO5HBqdTVgJOqxd76ckqNf+dn6eNBHJV8A3mmE1oxiv
         5DEkl/KA6U1BUvOpQzwBo/YQMZZZrggbCF1Hb34fpigNNA/NON2CtyFBcfj7rSCBOZuE
         LgGNfsPjRoXhAzTPUXxPMO8o8ZKYy0nqfHd6pmggEYV0kG2Zw7Kf/bb5g+G8dJtM31ja
         xv0nwPlxGUIkE6KtbyxX14T/fyFuEDgKFYIyYr6ZRn+CBao+xFP8PeWhk8XC/HRXzsuV
         Stxg==
X-Gm-Message-State: ALoCoQk8K2YLiCgDy8mPamHN3IQSsaVoFP23mjvarR8Rd6LVRERV7CpfsMBlrVIv8jn2Ksgtfkn6
X-Received: by 10.66.236.136 with SMTP id uu8mr12727195pac.13.1403908210577;
        Fri, 27 Jun 2014 15:30:10 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.66.227 with SMTP id i3ls642983igt.32.canary; Fri, 27 Jun
 2014 15:30:09 -0700 (PDT)
X-Received: by 10.50.122.73 with SMTP id lq9mr16017727igb.13.1403908208938;
        Fri, 27 Jun 2014 15:30:08 -0700 (PDT)
Original-Received: from mail-ig0-x22f.google.com (mail-ig0-x22f.google.com [2607:f8b0:4001:c05::22f])
        by mx.google.com with ESMTPS id u4si468800igh.60.2014.06.27.15.30.08
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 27 Jun 2014 15:30:08 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:4001:c05::22f as permitted sender) client-ip=2607:f8b0:4001:c05::22f;
Original-Received: by mail-ig0-f175.google.com with SMTP id h3so2503475igd.8
        for <std-proposals@isocpp.org>; Fri, 27 Jun 2014 15:30:08 -0700 (PDT)
X-Received: by 10.42.72.198 with SMTP id p6mr23177857icj.52.1403908208704;
        Fri, 27 Jun 2014 15:30:08 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.54.57])
        by mx.google.com with ESMTPSA id t1sm1021062igh.9.2014.06.27.15.30.06
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 27 Jun 2014 15:30:08 -0700 (PDT)
In-Reply-To: <CA+cyFgtNWh2sVd7ajaf+HwfLM2BiYGWjXEUVhOp84kpoVfrDkQ@mail.gmail.com>
X-Mailer: Apple Mail (2.1878.2)
X-Original-Sender: potswa@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of potswa@gmail.com designates 2607:f8b0:4001:c05::22f as permitted
 sender) smtp.mail=potswa@gmail.com;       dkim=pass header.i=@gmail.com;
       dmarc=pass (p=NONE dis=NONE) header.from=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:11589
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11589>

--Apple-Mail=_86B416BA-23C9-4A36-A216-1EA192BC5B5E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-06-28, at 3:43 AM, 'Geoffrey Romer' via ISO C++ Standard - Future P=
roposals <std-proposals@isocpp.org> wrote:

>=20
> On Thu, Jun 26, 2014 at 6:17 PM, David Krauss <potswa@gmail.com> wrote:
>=20
> That doesn't sound like something that should be taught. Students shouldn=
't have the impression that they should avoid move, or omit it just because=
 they can.
>=20
> Really? You wouldn't even teach students to omit move in an expression li=
ke this?
>=20
> Sink(std::move(Source()));

That's going a bit far. Students should know that move casts an object-sema=
ntic lvalue into a value-semantic rvalue, and application to an rvalue is a=
lways redundant. But that's not avoiding it, or opportunistic omission, it =
follows from the underlying theory.

> When fixing this code, it would be a good idea to add a comment that the =
result is expected to be constructed in-place, hence neither moved nor copi=
ed.
>=20
> By the way, this code is still giving you exactly what you asked for. Ask=
ing for a move when you actually want copy elision is, though reasonable, a=
 confusion of two completely different things.
>=20
> Can you give an example of when a programmer would not want a copy elisio=
n?

It's an optimization, not a choice. Teaching its interaction with moving is=
 asks the student to think about two theories at once, which almost by defi=
nition relegates it to a more advanced course.=20

> Say move() when you want a move.
>=20
> That's just begging the question; I'm trying to teach people how to know =
when they should want a move

I mean, say move() when you want an ownership transfer.

> Debug the rest, and be aware that moves still carry a cost which may be a=
s much as a copy.=20
>=20
> Would you say, then, that one should never apply std::move to a copyable =
type?

Absolutely not. For one thing, that often happens in generic programming. I=
 simply mean that while chasing performance bugs, after the fact of writing=
 a first draft, code with move semantics should not be dismissed out of han=
d as "already fast."

--=20

---=20
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 e=
mail 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-proposa=
ls/.

--Apple-Mail=_86B416BA-23C9-4A36-A216-1EA192BC5B5E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;06&ndash;28, at 3:43 AM, 'Geoffrey Romer' via ISO C++ Standard - Futu=
re Proposals &lt;<a href=3D"mailto:std-proposals@isocpp.org">std-proposals@=
isocpp.org</a>&gt; wrote:</div><br class=3D"Apple-interchange-newline"><blo=
ckquote type=3D"cite"><div dir=3D"ltr" style=3D"font-family: Helvetica; fon=
t-size: 12px; font-style: normal; font-variant: normal; font-weight: normal=
; letter-spacing: normal; line-height: normal; orphans: auto; text-align: s=
tart; text-indent: 0px; text-transform: none; white-space: normal; widows: =
auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=3D"gma=
il_extra"><div class=3D"gmail_quote"><br class=3D"Apple-interchange-newline=
">On Thu, Jun 26, 2014 at 6:17 PM, David Krauss<span class=3D"Apple-convert=
ed-space">&nbsp;</span><span dir=3D"ltr">&lt;<a href=3D"mailto:potswa@gmail=
..com" target=3D"_blank">potswa@gmail.com</a>&gt;</span><span class=3D"Apple=
-converted-space">&nbsp;</span>wrote:<br><blockquote class=3D"gmail_quote" =
style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-col=
or: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; positi=
on: static; z-index: auto;"><div style=3D"word-wrap: break-word;"><br><div>=
<div class=3D""><div>That doesn&rsquo;t sound like something that should be=
 taught. Students shouldn&rsquo;t have the impression that they should avoi=
d move, or omit it just because they can.</div></div></div></div></blockquo=
te><div><br></div><div>Really? You wouldn't even teach students to omit mov=
e in an expression like this?</div><div><br></div><div>Sink(std::move(Sourc=
e()));</div></div></div></div></blockquote><div><br></div><div>That&rsquo;s=
 going a bit far. Students should know that move casts an object-semantic l=
value into a value-semantic rvalue, and application to an rvalue is always =
redundant. But that&rsquo;s not avoiding it, or opportunistic omission, it =
follows from the underlying theory.</div><br><blockquote type=3D"cite"><div=
 dir=3D"ltr" style=3D"font-family: Helvetica; font-size: 12px; font-style: =
normal; font-variant: normal; font-weight: normal; letter-spacing: normal; =
line-height: normal; orphans: auto; text-align: start; text-indent: 0px; te=
xt-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -=
webkit-text-stroke-width: 0px;"><div class=3D"gmail_extra"><div class=3D"gm=
ail_quote"><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0=
..8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border=
-left-style: solid; padding-left: 1ex;"><div style=3D"word-wrap: break-word=
;"><div>When fixing this code, it would be a good idea to add a comment tha=
t the result is expected to be constructed in-place, hence neither moved no=
r copied.</div><div><br></div><div>By the way, this code is still giving yo=
u exactly what you asked for. Asking for a move when you actually want copy=
 elision is, though reasonable, a confusion of two completely different thi=
ngs.</div></div></blockquote><div><br></div><div>Can you give an example of=
 when a programmer would not want a copy elision?</div></div></div></div></=
blockquote><div><br></div><div>It&rsquo;s an optimization, not a choice. Te=
aching its interaction with moving is asks the student to think about two t=
heories at once, which almost by definition relegates it to a more advanced=
 course.&nbsp;</div><div><br></div><blockquote type=3D"cite"><div dir=3D"lt=
r" style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; fo=
nt-variant: normal; font-weight: normal; letter-spacing: normal; line-heigh=
t: normal; orphans: auto; text-align: start; text-indent: 0px; text-transfo=
rm: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px;"><div class=3D"gmail_extra"><div class=3D"gmail_quote"=
><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; bord=
er-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-styl=
e: solid; padding-left: 1ex; position: static; z-index: auto;"><div style=
=3D"word-wrap: break-word;"><div>Say<span class=3D"Apple-converted-space">&=
nbsp;</span><font face=3D"Courier">move()</font><span class=3D"Apple-conver=
ted-space">&nbsp;</span>when you want a move.</div></div></blockquote><div>=
<br></div><div>That's just begging the question; I'm trying to teach people=
 how to know when they should want a move</div></div></div></div></blockquo=
te><div><br></div><div>I mean, say move() when you want an ownership transf=
er.</div><br><blockquote type=3D"cite"><div dir=3D"ltr" style=3D"font-famil=
y: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; fo=
nt-weight: normal; letter-spacing: normal; line-height: normal; orphans: au=
to; text-align: start; text-indent: 0px; text-transform: none; white-space:=
 normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">=
<div class=3D"gmail_extra"><div class=3D"gmail_quote"><blockquote class=3D"=
gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; bo=
rder-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left=
: 1ex;"><div style=3D"word-wrap: break-word;">Debug the rest, and be aware =
that moves still carry a cost which may be as much as a copy.&nbsp;</div></=
blockquote><div><br></div><div>Would you say, then, that one should never a=
pply std::move to a copyable type?</div></div></div></div></blockquote><br>=
</div><div>Absolutely not. For one thing, that often happens in generic pro=
gramming. I simply mean that while chasing performance bugs, after the fact=
 of writing a first draft, code with move semantics should not be dismissed=
 out of hand as &ldquo;already fast.&rdquo;</div><div><br></div></body></ht=
ml>

<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 />

--Apple-Mail=_86B416BA-23C9-4A36-A216-1EA192BC5B5E--

.
