220 32457 <8361ebed-8ecb-44c6-9b36-6fbce460a952@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Allow Structured Binding Outside of Variable Declaration
Date: Mon, 15 May 2017 07:54:09 -0700 (PDT)
Lines: 101
Approved: news@gmane.org
Message-ID: <8361ebed-8ecb-44c6-9b36-6fbce460a952@isocpp.org>
References: <e02d79e8-7d80-4614-bd25-e73fb43dad9d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1452_1525024644.1494860049992"
X-Trace: blaine.gmane.org 1494860050 25506 195.159.176.226 (15 May 2017 14:54:10 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 15 May 2017 14:54:10 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBEUC47EAKGQESMSTUAA@isocpp.org Mon May 15 16:54:06 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBEUC47EAKGQESMSTUAA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f198.google.com ([209.85.161.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBEUC47EAKGQESMSTUAA@isocpp.org>)
	id 1dAHNu-0006XU-7c
	for gclcip-std-proposals@m.gmane.org; Mon, 15 May 2017 16:54:06 +0200
Original-Received: by mail-yw0-f198.google.com with SMTP id x186sf4538145ywg.10
        for <gclcip-std-proposals@m.gmane.org>; Mon, 15 May 2017 07:54:12 -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=tFXowxjbU0m+eXYI3Pji6yQbU3qeW9bRH4UhX8L5mYQ=;
        b=UtvRJITwT1N+EMHh+AHfFtKUTK4nHDlOxom9wxoKkW/U03ncdO0pA3bqS9dDJIKKiQ
         W+bILUosO0Z42YTdWlS13h6N2x4fg9p8NXzdf6jo7cebrwpK7JH3sLY2s2e8gVcV2Hjv
         sFpDUv05WakXtpPX+UkU33rsOkqu9PAubAWxlmoVE0cluz5ZOYPU772WXRNy+8XcV6zP
         tMHO0VZq98kfdAWbEBQhZE4M20Akhlti0wQvnXdeQ6wygTJyZFklGr6TcxQGDKME4LrZ
         h+HnNfP9A5wM7oeHL9V7PqpzsSNnC6qvvk5/1ONYfB+Ey/JjenxVE+c4PPJ2Q8tI0jlo
         86yA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        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=tFXowxjbU0m+eXYI3Pji6yQbU3qeW9bRH4UhX8L5mYQ=;
        b=qkTnLSAjNwN94BnTX7YDwIMTpvqnZKxPgkSrwvyogVKiw30Iyvh5CNmyUGmCi6zj+0
         RzL9e6qLGcoy/A4r4PcqWY7hVxnaZJN7bJxmG+Z+Zm0SkxyhBfoNXA7yM++iyCXIKCN+
         SAy5zzzKCMJUgqZwwBZdP4pscHRvgpYJj6larQuEjpyRaX7YuTlb7VhJ/sDZuY1V17Vj
         gw5mljyFYKplJpM2uEZcyAvvMu14Ok305na9jGDii0zyFYi5jwnKfuOLqZZeRUwN41hV
         mgNvMPalOKDpiobrI6glyYGg31satWGJHslFvPzRQ7XVDRE61qpYk6b1R/D1n4O3EXi/
         1x9g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        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=tFXowxjbU0m+eXYI3Pji6yQbU3qeW9bRH4UhX8L5mYQ=;
        b=JSStupPgpGRdj0RNMPa4qgKrVHqGtDUzOBz2a4vcfTviNpqWnyQN72a94XcKA7/qlj
         Ng//d9OxbzjrAVxZYiXE3MEa1g5fxRJgVtcIzIpZlHgqQ4GaOBb8FoTvVCUjfbrAseCc
         waN/OkWDx31v1vM0rQ/CWPI78dbZEaUGcK1TpZ1iJ1D9/ESOws+w79IkVIwrUCtyl8Yz
         KR5WaJ9MiXwq5V4XjTYamtzoLeGowwXehi0oZ8UkN2S44SPF765ppqbCbT14GNHDpYYy
         rudWk6CxF6V5GBbYgh8WixFdCd9F4jWd5SmKLALRuA+Tb4ep7LXqcg4A+J+m94eAkS1v
         6eCw==
X-Gm-Message-State: AODbwcAOW7/vA/ITMvcTH3kOfQyjQCpD6rOv6+2Tl58hQuPQItjGlBi8
	+wa5ZeVyF5sQrA==
X-Received: by 10.13.212.203 with SMTP id w194mr3180304ywd.38.1494860051528;
        Mon, 15 May 2017 07:54:11 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.60.102 with SMTP id j35ls13582508ote.13.gmail; Mon, 15 May
 2017 07:54:10 -0700 (PDT)
X-Received: by 10.157.40.242 with SMTP id s105mr133404ota.5.1494860050528;
        Mon, 15 May 2017 07:54:10 -0700 (PDT)
In-Reply-To: <e02d79e8-7d80-4614-bd25-e73fb43dad9d@isocpp.org>
X-Original-Sender: jmckesson@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:32457
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32457>

------=_Part_1452_1525024644.1494860049992
Content-Type: multipart/alternative; 
	boundary="----=_Part_1453_1096682095.1494860049992"

------=_Part_1453_1096682095.1494860049992
Content-Type: text/plain; charset="UTF-8"

On Monday, May 15, 2017 at 6:00:06 AM UTC-4, Antonio Perez wrote:
>
> Structured Binding is a language feature that has a lot of potential, 
> although as of C++17 it's a pretty limited feature. (This is part of a 
> series of proposals generalizing structured binding). I propose allowing 
> structured binding outside of variable declaration:
>
> int a = 0;
> //Random code
> std::string text ="";
> //More code
> [a,text] = tuple(3, "Hello, world");
>
>
You still need the `auto` there. You may not be creating the variables `a` 
and `text`, but you *are* creating a hidden variable to store the prvalue. 
So it's still a variable declaration.

A more important question is this: exactly how does this work? Structured 
binding's behavior is a bit different for structs/arrays than it is for 
tuple-like types. If that were a struct, then `a` and `text` would not be 
reference variables to those members. They would actually *be those members*; 
the compiler would substitute the `a` and `text` identifiers for exactly 
those members.

So how would that work if the variable already exists?

-- 
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/8361ebed-8ecb-44c6-9b36-6fbce460a952%40isocpp.org.

------=_Part_1453_1096682095.1494860049992
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Monday, May 15, 2017 at 6:00:06 AM UTC-4, Antonio Perez=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Struct=
ured Binding is a language feature that has a lot of potential, although as=
 of C++17 it&#39;s a pretty limited feature. (This is part of a series of p=
roposals generalizing structured binding). I propose allowing structured bi=
nding outside of variable declaration:<div><br></div><div><div style=3D"bac=
kground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:s=
olid;border-width:1px;word-wrap:break-word"><code><div><font color=3D"#6600=
66"><span style=3D"color:#008">int</span><span style=3D"color:#000"> a </sp=
an><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#066">0</span><span style=3D"color:#660">;</span><span=
 style=3D"color:#000"><br></span><span style=3D"color:#800">//Random code</=
span><span style=3D"color:#000"><br>std</span><span style=3D"color:#660">::=
</span><span style=3D"color:#008">string</span><span style=3D"color:#000"> =
text </span><span style=3D"color:#660">=3D</span><span style=3D"color:#080"=
>&quot;&quot;</span><span style=3D"color:#660">;</span><span style=3D"color=
:#000"><br></span><span style=3D"color:#800">//More code</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#660">[</span><span style=
=3D"color:#000">a</span><span style=3D"color:#660">,</span><span style=3D"c=
olor:#000">text</span><span style=3D"color:#660">]</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:=
#000"> tuple</span><span style=3D"color:#660">(</span><span style=3D"color:=
#066">3</span><span style=3D"color:#660">,</span><span style=3D"color:#000"=
> </span><span style=3D"color:#080">&quot;Hello, world&quot;</span><span st=
yle=3D"color:#660">);</span></font></div></code></div><br></div></div></blo=
ckquote><div><br>You still need the `auto` there. You may not be creating t=
he variables `a` and `text`, but you <i>are</i> creating a hidden variable =
to store the prvalue. So it&#39;s still a variable declaration.<br><br>A mo=
re important question is this: exactly how does this work? Structured bindi=
ng&#39;s behavior is a bit different for structs/arrays than it is for tupl=
e-like types. If that were a struct, then `a` and `text` would not be refer=
ence variables to those members. They would actually <i>be those members</i=
>; the compiler would substitute the `a` and `text` identifiers for exactly=
 those members.<br><br>So how would that work if the variable already exist=
s?<br></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/8361ebed-8ecb-44c6-9b36-6fbce460a952%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8361ebed-8ecb-44c6-9b36-6fbce460a952=
%40isocpp.org</a>.<br />

------=_Part_1453_1096682095.1494860049992--

------=_Part_1452_1525024644.1494860049992--

.
