220 31890 <CAF8PYMgi7mk_fHs=cyYhW4rQad6uDLXrFd7Ef2m7g8Q143p2eg@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Vitali Lovich <vlovich@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: This variable should not be named: an identifier
 (not) to remember
Date: Thu, 30 Mar 2017 03:41:37 +0000
Lines: 142
Approved: news@gmane.org
Message-ID: <CAF8PYMgi7mk_fHs=cyYhW4rQad6uDLXrFd7Ef2m7g8Q143p2eg@mail.gmail.com>
References: <985b9b2a-c734-45eb-95f4-db4dc0d309a1@isocpp.org>
 <14211602.1P4LjlnQMh@tjmaciei-mobl1> <CAGsORuBepjjTQxa0w+9Z_v+irrc6QwxqmUv98dTRarUCVHHY+A@mail.gmail.com>
 <2235919.4GAIbDEcRC@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a113dd48afdec35054bea7817
X-Trace: blaine.gmane.org 1490845315 6826 195.159.176.226 (30 Mar 2017 03:41:55 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 30 Mar 2017 03:41:55 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCFIZX46Q4HRB7H46HDAKGQEDMKRR5A@isocpp.org Thu Mar 30 05:41:49 2017
Return-path: <std-proposals+bncBCFIZX46Q4HRB7H46HDAKGQEDMKRR5A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt0-f199.google.com ([209.85.216.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCFIZX46Q4HRB7H46HDAKGQEDMKRR5A@isocpp.org>)
	id 1ctQxz-0000VR-Da
	for gclcip-std-proposals@m.gmane.org; Thu, 30 Mar 2017 05:41:43 +0200
Original-Received: by mail-qt0-f199.google.com with SMTP id h56sf12538095qtc.10
        for <gclcip-std-proposals@m.gmane.org>; Wed, 29 Mar 2017 20:41:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to: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=61q/XUT/tTUlv0f/cjSdGfp5A7JpJo9maXarVKSyw2U=;
        b=v+ipBA094yyPqljMuHdrTvDJXNCsN8RFQLOhYBW16qpTkzszcrArrfZHppaBgq39ge
         RtK2r2hSFbYr2XLbo5dcupavTxICOmUAbEbSt5rB5toMfgLTxbpAROifxcu7pk++2TvE
         EluT7Gj6GeqQVFCputSRGEwTtN9UCGp5QgAWh66g39fA6YmWQ5jpzjifiggRhza4gSQB
         Ytch7eYRIKrJZ2zBUp6De0lxw/vGAw1Y2dHKHfHqdSVPl5QsbpTspCY5f6JsTIe+3zXD
         7dyRDdt/SjKKoxykVDGPE/0d+lkDXQQWGr7LFNr7fQw7bAFU97bF9dASb7404qQmx3jB
         Ic5g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to: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=61q/XUT/tTUlv0f/cjSdGfp5A7JpJo9maXarVKSyw2U=;
        b=fy22q4z1DZvQ9KxkiybGuzqHlMAgDewtMVxxiv5adJra+Ju8sxWXNHAUIk1lpsqseS
         LzYXrMusjYUb7vyD1Zh32zeN3yzvp/uyJXEnQEPohmi11BQrjt6sYbXnKBdMvIrpXw2a
         aglMkbqIcVKwmL6D+obrPSqcNhRVCrgPHaOf1Xk5qvEyo2Qn9ufYFS3QgoOhELC2hwBn
         pSQywN8iZ3U8RcTv7H+DbVcJDAr4eD2lKAoiXbAA+1Ho8ia9KpcI70UzsGg5fMyZgvwW
         N03BzsU47RnZ9LGWtB6AUaAIjk9Mw5O3ErGHauyOikN3x41/G76AN+hf93mMY7IQYerf
         jXLA==
X-Gm-Message-State: AFeK/H3Plj1fA7TfZrcU3ukLawsXVlju+A/zUQKLUNSqTbddJpwcLGK1Jr0pFXK8tNBQPA==
X-Received: by 10.200.49.51 with SMTP id g48mr1507838qtb.69.1490845309095;
        Wed, 29 Mar 2017 20:41:49 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.15.38 with SMTP id 35ls3534149ott.19.gmail; Wed, 29 Mar
 2017 20:41:48 -0700 (PDT)
X-Received: by 10.202.72.77 with SMTP id v74mr2047647oia.186.1490845308231;
        Wed, 29 Mar 2017 20:41:48 -0700 (PDT)
Original-Received: from mail-oi0-x235.google.com (mail-oi0-x235.google.com. [2607:f8b0:4003:c06::235])
        by mx.google.com with ESMTPS id x131si404128oif.209.2017.03.29.20.41.48
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 29 Mar 2017 20:41:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of vlovich@gmail.com designates 2607:f8b0:4003:c06::235 as permitted sender) client-ip=2607:f8b0:4003:c06::235;
Original-Received: by mail-oi0-x235.google.com with SMTP id r203so18292471oib.3
        for <std-proposals@isocpp.org>; Wed, 29 Mar 2017 20:41:48 -0700 (PDT)
X-Received: by 10.202.191.68 with SMTP id p65mr1874432oif.152.1490845307888;
 Wed, 29 Mar 2017 20:41:47 -0700 (PDT)
In-Reply-To: <2235919.4GAIbDEcRC@tjmaciei-mobl1>
X-Original-Sender: vlovich@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of vlovich@gmail.com
 designates 2607:f8b0:4003:c06::235 as permitted sender) smtp.mailfrom=vlovich@gmail.com;
       dmarc=pass (p=NONE sp=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: <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:31890
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31890>

--001a113dd48afdec35054bea7817
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Mar 28, 2017 at 10:52 AM Thiago Macieira <thiago@macieira.org>
wrote:

> On ter=C3=A7a-feira, 28 de mar=C3=A7o de 2017 09:53:51 PDT Zhihao Yuan wr=
ote:
> > Whether a call to get<0>(anon) being made
> > certainly has difference, because it can have
> > observable effect.
>
> It does not, so it cannot have an observable effect.

doesnt it? If a function returns a Shared_ptr of a string and string_view
that references the string, if you do:

    auto __ =3D getstr()
    auto [__, view] =3D getstr()

The behavior is observably different between the two cases depending on
whether the compiler elides the get(0).  If you elide the get(0) in the
second example isn't view going to point potentially freed memory?  It
seems like there needs to be a distinction for structured binding between
"don't care about name but keep alive for RAII" vs "don't care about value
at all".  There may be cases in the former where a compiler finds room for
optimization so it'll be equivalent in many cases.  It also has the added
benefit of ensuring that the performance and lifetime behavior is identical
to when you provide an identifier which is great for consistency and
teachability.

Personally I think the "ignore" semantic is not as interesting - if
performance is a concern then you'll have to be slightly more explicit or
if it's common enough a separate mechanism can be developed.


> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>
> --
> 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/2235919.4GAI=
bDEcRC%40tjmaciei-mobl1
> .
>

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAF8PYMgi7mk_fHs%3DcyYhW4rQad6uDLXrFd7Ef2m7g8Q14=
3p2eg%40mail.gmail.com.

--001a113dd48afdec35054bea7817
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div><br><div class=3D"gmail_quote"><div>On Tue, Mar 28, 2017 at 10:52 AM T=
hiago Macieira &lt;<a href=3D"mailto:thiago@macieira.org">thiago@macieira.o=
rg</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On ter=C3=A7a-fei=
ra, 28 de mar=C3=A7o de 2017 09:53:51 PDT Zhihao Yuan wrote:<br class=3D"gm=
ail_msg">
&gt; Whether a call to get&lt;0&gt;(anon) being made<br class=3D"gmail_msg"=
>
&gt; certainly has difference, because it can have<br class=3D"gmail_msg">
&gt; observable effect.<br class=3D"gmail_msg">
<br class=3D"gmail_msg">
It does not, so it cannot have an observable effect.</blockquote><div>doesn=
t it? If a function returns a Shared_ptr of a string and string_view that r=
eferences the string, if you do:</div><div><br></div><div>=C2=A0 =C2=A0 aut=
o __ =3D getstr()</div><div>=C2=A0 =C2=A0 auto [__, view] =3D getstr()</div=
><div><br></div><div>The behavior is observably different between the two c=
ases depending on whether the compiler elides the get(0).=C2=A0 If you elid=
e the get(0) in the second example isn&#39;t view going to point potentiall=
y freed memory?=C2=A0 It seems like there needs to be a distinction for str=
uctured binding between &quot;don&#39;t care about name but keep alive for =
RAII&quot; vs &quot;don&#39;t care about value at all&quot;.=C2=A0 There ma=
y be cases in the former where a compiler finds room for optimization so it=
&#39;ll be equivalent in many cases.=C2=A0 It also has the added benefit of=
 ensuring that the performance and lifetime behavior is identical to when y=
ou provide an identifier which is great for consistency and teachability.</=
div><div><br></div><div>Personally I think the &quot;ignore&quot; semantic =
is not as interesting - if performance is a concern then you&#39;ll have to=
 be slightly more explicit or if it&#39;s common enough a separate mechanis=
m can be developed.</div><div><br></div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br =
class=3D"gmail_msg">
--<br class=3D"gmail_msg">
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"noref=
errer" class=3D"gmail_msg" target=3D"_blank">macieira.info</a> - thiago (AT=
) <a href=3D"http://kde.org" rel=3D"noreferrer" class=3D"gmail_msg" target=
=3D"_blank">kde.org</a><br class=3D"gmail_msg">
=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center<br cl=
ass=3D"gmail_msg">
<br class=3D"gmail_msg">
--<br class=3D"gmail_msg">
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br class=3D"gmail_msg=
">
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" class=3D"=
gmail_msg" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br c=
lass=3D"gmail_msg">
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" class=3D"gmail_msg" target=3D"_blank">std-proposals@isocpp.org</a>.<b=
r class=3D"gmail_msg">
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2235919.4GAIbDEcRC%40tjmaciei-mobl1" =
rel=3D"noreferrer" class=3D"gmail_msg" target=3D"_blank">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/2235919.4GAIbDEcRC%40tjmaciei-mo=
bl1</a>.<br class=3D"gmail_msg">
</blockquote></div></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/CAF8PYMgi7mk_fHs%3DcyYhW4rQad6uDLXrFd=
7Ef2m7g8Q143p2eg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAF8PYMgi7mk_fH=
s%3DcyYhW4rQad6uDLXrFd7Ef2m7g8Q143p2eg%40mail.gmail.com</a>.<br />

--001a113dd48afdec35054bea7817--

.
