220 32485 <08ff73f1-6989-393e-ee4e-8158af2e7bed@honermann.net> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Tom Honermann <tom@honermann.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Allow Structured Binding Outside of Variable Declaration
Date: Tue, 16 May 2017 10:29:03 -0400
Lines: 74
Approved: news@gmane.org
Message-ID: <08ff73f1-6989-393e-ee4e-8158af2e7bed@honermann.net>
References: <e02d79e8-7d80-4614-bd25-e73fb43dad9d@isocpp.org>
 <10b21241-b683-44d5-82ce-90681b2643a4@isocpp.org>
 <CAFk2RUbf5skMEcsLd_hUiZrib2bGCvyrJbgsx9LV-rXaj=fBZw@mail.gmail.com>
 <CAFk2RUbgg7UMc_mFGKQZF7-PVVbEDsdoZoXL46oyxr+PLRTfvw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1494944946 19541 195.159.176.226 (16 May 2017 14:29:06 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 16 May 2017 14:29:06 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.2.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDBNXSHG6UDBBMUZ5TEAKGQE5ZGMVNI@isocpp.org Tue May 16 16:29:02 2017
Return-path: <std-proposals+bncBDBNXSHG6UDBBMUZ5TEAKGQE5ZGMVNI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f70.google.com ([209.85.218.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDBNXSHG6UDBBMUZ5TEAKGQE5ZGMVNI@isocpp.org>)
	id 1dAdTB-0004w5-P1
	for gclcip-std-proposals@m.gmane.org; Tue, 16 May 2017 16:29:01 +0200
Original-Received: by mail-oi0-f70.google.com with SMTP id t9sf23782829oih.13
        for <gclcip-std-proposals@m.gmane.org>; Tue, 16 May 2017 07:29:07 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1494944947; cv=pass;
        d=google.com; s=arc-20160816;
        b=C0F7xucLNYnWlnQHwUbuANWucDKRRbNN484tlhI2Kn7Mt2bUQej65wNM0ChaPKq/n0
         m7hACyIT0avBEkNBNpykiQaEHG/lijZjwr8aUlOTChFy9gN/Lyr1rvyPdZn0vDz3U6yt
         xjq+ul31ATVjtJ8zzmYE3gYqoV/CC6mM+V+m2uIwgz44kHowDaRLGiuO3NZe2Y1cYMdI
         G15r6AqFTciqmC+AwycOjCNqzo+/xCvGsk8tlUnNZSj/xwxIH4U/zWE+fqudNyc6d7ji
         m/1onfZYedeoiKTfiEbODuHA2E5qgC0Vr2skLppinNBeI8H/EZ6nSMU7c06EeCdSoK1K
         q7pg==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:to:subject
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=3rgxuLLrNYKGrQwpVx9HIwAHwcVmiLHjWgRoXn1raDQ=;
        b=V2lfN7gPKF9gty3KqAaMcIfzTuwmQlVdfFE5GczsXM1FFl2IuuCf2wREUHTq5QLMgy
         tonBjyiX4OyGQBc5oWOaLsMgbHYhRrKxwcPcklEstv1ez8EAEPurLE5s5SamFqe/o5yc
         fK3s5X2FhN2/tV+MfnKd/2ft/QWAsrB8Q4/zc8WcSdG9CWls2EEB6bZ0V6EM6ABj3zCO
         vdue++wGbaRnxmvZK4cOW+77CHOPOYwW5Dle1vYZCTkprc3IRF8Ih/F8So34m56mhx8l
         SBQhkfu4uKAw6nJc3BGk8O5dndz2q+r1D7wT/fOIt5TFLKJm0dQfK17c9ZNHwn3LMi+2
         kf5g==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=neutral (google.com: 67.192.241.139 is neither permitted nor denied by best guess record for domain of tom@honermann.net) smtp.mailfrom=tom@honermann.net
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-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=3rgxuLLrNYKGrQwpVx9HIwAHwcVmiLHjWgRoXn1raDQ=;
        b=EYaeIJTlmIGpwEe3wXxudmCxtvs55hD43k9vnxsQMVVOaFgmTtuz75TvS01YufxiUF
         Y5a2y/UYppsJs9gURAYF4VK4MOVgFy2xv1fyLBkfa9LG/hsqD8cP60LjaxyyktICQ3lL
         OsnIobIivzXHW+WZN1t6hwTqiTEo2mX5bVkcx3jOnvuBynJ9QBuDXH+RdWU/n7iQ1iJA
         eXB31pW7g9k4z/JHj4EFUaE6R0GrgFCmFuQ6kzIVUET7fawNkE1LuZbWusbScCmv7/dA
         AbRcv5heTNd8N3DxhUd2coGsJxp4SrO9En8ZasHknAeiOeugYrDrRZOm1mIjEwyzYXcz
         DqCA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-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=3rgxuLLrNYKGrQwpVx9HIwAHwcVmiLHjWgRoXn1raDQ=;
        b=Dd0GQdl7q4w8JEYZHaD4wXag1HulSQJSPlZHKkYiMh+0PjWjUiTFhx2Jgrd7C9ys5Z
         sLqlSJWzribKNZHGMBkLA7pl/bOVA/Ez7pTBvtuwXWUSkrPx7vNkBDPerMFiLG+aROF7
         23PutzrD705Tb5pMbRAI5HgBbB/YFE4SPnz+jV1Ecv2eYhpicB0kS9sUsY7RwjcIJeVk
         e/ysBVlPxF6efCNNFF/q2W1RLPWzJBhHp0kB2+7syiGr6VWGB6U0i5PKccl9nOwUErtn
         U57cUhuW5LC/ITn/6iixlSit9t0TArvCTggHQAUYmmnMzInYKjaBe+nsEQWJJIif7XD0
         p5NA==
X-Gm-Message-State: AODbwcCv06QN/mzleTWmq/xLPyjQBRuNdUETi1YKFSq5txDJO6lMPEE2
	oQJhEZM22qlliA==
X-Received: by 10.157.23.6 with SMTP id i6mr5627635ota.86.1494944947113;
        Tue, 16 May 2017 07:29:07 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.37.235 with SMTP id q98ls1518642ota.49.gmail; Tue, 16 May
 2017 07:29:06 -0700 (PDT)
X-Received: by 10.157.47.70 with SMTP id h64mr6210118otb.23.1494944946225;
        Tue, 16 May 2017 07:29:06 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1494944946; cv=none;
        d=google.com; s=arc-20160816;
        b=i6+/fFMQYZXiD+a9Flq9ol2pX9UmUx/A0nKVd78fFGZMRSj4fNf/dc1TfXppwxQdxo
         MLw+aXRKJLyzQm3GJgLZqFl7Vf2JOranr0qEHfnqVrQ+ROJ9bF83ROu/orOpxy6tt2Ug
         GNYYDZHkiKwZ96Tr7bN5McHVcNdSaY7orWj3sU/lNXd5gv+gNcxR9ERxQdnChVfTpcPC
         iII18CZds7nf/F5ivL+DrYaHptZLeCAEV5ybkp70gosO9gLU9gA4l3Qvc0Wf7Su0Anr3
         yUsQdR53MGiZbR2ARQp3MSDFixHpuQkHHJ0iGUBdyBTfuzXfBwmUEjPoV9Xtyo0QWfYj
         wLRQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:in-reply-to:mime-version:user-agent:date
         :message-id:from:references:to:subject:arc-authentication-results;
        bh=KhnvCbex6nqp7QeSrkdfDnk7bm6yRv/DNm0Pl7hytF0=;
        b=S4dfT3awROXBY7O8ZK1BXT5IjojP1lwTtrNFItic8MmJB23sBxopDmm2Y455nkSfmj
         rBaUmERzbCrsmnG+sgru7FQPJudDrZW+PMIj4Cwk+qCu4IROF/C1/GatWsPUow7ZVUON
         mXhE1yhsvC0cqRsTEzegTtzHEcaUjQTufdafV+edD1PSof7eLchGmgytqfXxTgszXcwd
         MCd/9uAaVea5lzaVBYwDZ1H7N6OPwXddqWny745pi0MgoEQ+VPRZly1L7FqpM5vqIUK2
         +I6hVk+W8bd+1SOjjiDkhm/dZxVD/T4GXM1EJHeaS2Gpz3tg7p0VmHMpnzecSEkDugD4
         p2/A==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: 67.192.241.139 is neither permitted nor denied by best guess record for domain of tom@honermann.net) smtp.mailfrom=tom@honermann.net
Original-Received: from smtp139.dfw.emailsrvr.com (smtp139.dfw.emailsrvr.com. [67.192.241.139])
        by mx.google.com with ESMTPS id v187si962853oia.196.2017.05.16.07.29.06
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 16 May 2017 07:29:06 -0700 (PDT)
Received-SPF: neutral (google.com: 67.192.241.139 is neither permitted nor denied by best guess record for domain of tom@honermann.net) client-ip=67.192.241.139;
Original-Received: from smtp22.relay.dfw1a.emailsrvr.com (localhost [127.0.0.1])
	by smtp22.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id AB8CD203E7
	for <std-proposals@isocpp.org>; Tue, 16 May 2017 10:29:05 -0400 (EDT)
X-Auth-ID: tom@honermann.net
Original-Received: by smtp22.relay.dfw1a.emailsrvr.com (Authenticated sender: tom-AT-honermann.net) with ESMTPSA id 6A404203BC
	for <std-proposals@isocpp.org>; Tue, 16 May 2017 10:29:05 -0400 (EDT)
X-Sender-Id: tom@honermann.net
Original-Received: from [192.168.1.7] (pool-173-53-30-126.rcmdva.fios.verizon.net [173.53.30.126])
	(using TLSv1.2 with cipher DHE-RSA-AES128-SHA)
	by 0.0.0.0:587 (trex/5.7.12);
	Tue, 16 May 2017 10:29:05 -0400
In-Reply-To: <CAFk2RUbgg7UMc_mFGKQZF7-PVVbEDsdoZoXL46oyxr+PLRTfvw@mail.gmail.com>
X-Original-Sender: tom@honermann.net
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 67.192.241.139 is neither permitted nor denied by best guess
 record for domain of tom@honermann.net) smtp.mailfrom=tom@honermann.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:32485
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32485>

On 05/16/2017 01:52 AM, Ville Voutilainen wrote:
> On 16 May 2017 at 08:37, Ville Voutilainen <ville.voutilainen@gmail.com> wrote:
>> On 16 May 2017 at 08:13, Arthur O'Dwyer <arthur.j.odwyer@gmail.com> wrote:
>>>> [a,text] = tuple(3, "Hello, world");
>>>
>>> No, that's just std::tie; we have that.
>>> What we don't have in any sane form, but which IMO every parser-programmer
>>> is waiting for, is
>>>
>>>      std::pair<Key, const char *> parseKey(const char *);
>>>      std::pair<Value, const char *> parseValue(const char *);
>>>
>>>      std::pair<KVPair, const char *> parseKVPair(const char *in)
>>>      {
>>>          if (*in++ != '(') throw Failure();
>>>          Key k [,in] = parseKey(in);
>>>          if (*in++ != ',') throw Failure();
>>>          Value v [,in] = parseValue(in);
>>>          if (*in++ != ')') throw Failure();
>>>          return {KVPair(k, v), in};
>>>      }
>>>
>>> Now, this is terrible syntax, and it also doesn't really work if you were to
>>> put the "const char *" first in the return type instead of last. So I'm by
>>> no means proposing this syntax. I'm just using it to illustrate the semantic
>> So your point is that std::tie does "assignment bindings", structured
>> bindings do
>> "initializing bindings", but neither of them can do a mixture of both.
>
> On that note, I can cobble together something like
>
>       std::pair<Key, const char *> parseKey(const char *);
>       std::pair<Value, const char *> parseValue(const char *);
>
>       std::pair<KVPair, const char *> parseKVPair(const char *in)
>       {
>           if (*in++ != '(') throw Failure();
>           auto [Key k, =in] = parseKey(in);
>           if (*in++ != ',') throw Failure();
>           auto [Value v, =in] = parseValue(in);
>           if (*in++ != ')') throw Failure();
>           return {KVPair(k, v), in};
>       }
>
> So two things there, allow specifying the type of a binding (my
> favorite thing that structured bindings
> don't let me do) and allow the binding to assign instead of initializing.
>
I like this, but still prefer the following syntax discussed in Issaquah 
to specify a type constraint rather than something that looks like a 
variable declaration with non-obvious conversion semantics:

      std::pair<Key, const char *> parseKey(const char *);
      std::pair<Value, const char *> parseValue(const char *);

      std::pair<KVPair, const char *> parseKVPair(const char *in)
      {
          if (*in++ != '(') throw Failure();
          auto [k -> Key, =in] = parseKey(in);
          if (*in++ != ',') throw Failure();
          auto [v -> Value, =in] = parseValue(in);
          if (*in++ != ')') throw Failure();
          return {KVPair(k, v), in};
      }

Tom.


-- 
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/08ff73f1-6989-393e-ee4e-8158af2e7bed%40honermann.net.

.
