220 32491 <ffcb4ca3-5fb8-41b4-8b38-cfd287148cd5@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 13:01:11 -0400
Lines: 66
Approved: news@gmane.org
Message-ID: <ffcb4ca3-5fb8-41b4-8b38-cfd287148cd5@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>
 <08ff73f1-6989-393e-ee4e-8158af2e7bed@honermann.net>
 <CAFk2RUaBhq7KVukgRMvqBMuBiBwZmCf+xZpD9jRtBberFoU2Rg@mail.gmail.com>
 <c70b0cd6-fa3e-d215-3fef-06eb231ed3cd@honermann.net>
 <CAFk2RUbiUZ4n_mXdBUTGEZSsh5C=Mf0hKbKu76PKzCCWnZfrgA@mail.gmail.com>
 <d184a83a-4f99-a8d2-6bba-1b8aeedd797c@honermann.net>
 <20170516164245.GA16348@fukushima.lysator.liu.se>
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 1494954081 7168 195.159.176.226 (16 May 2017 17:01:21 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 16 May 2017 17:01:21 +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+bncBDBNXSHG6UDBBWHA5TEAKGQENOJLXWY@isocpp.org Tue May 16 19:01:12 2017
Return-path: <std-proposals+bncBDBNXSHG6UDBBWHA5TEAKGQENOJLXWY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f200.google.com ([209.85.223.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDBNXSHG6UDBBWHA5TEAKGQENOJLXWY@isocpp.org>)
	id 1dAfqO-0001VW-MG
	for gclcip-std-proposals@m.gmane.org; Tue, 16 May 2017 19:01:08 +0200
Original-Received: by mail-io0-f200.google.com with SMTP id l10sf103773797ioi.5
        for <gclcip-std-proposals@m.gmane.org>; Tue, 16 May 2017 10:01:14 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1494954074; cv=pass;
        d=google.com; s=arc-20160816;
        b=ivqJssKjp3jKUH3enL9i4D8/t0Dd2HDljs97wQh+iGYTRdVYx2SldbGFVk96KVEWD1
         UYLZFXJPD9QckQKnITX0lT+zmh9DLK4AOVhZYdKBpIE8/s9kHC9SIq/kIDj1UTUsTrj9
         KKsDHEc9gzF/4ZCpGObOj1Q9vxUOE0wxvws67xXxVyqeryswGVYtaBy2DQNpGI0obNeh
         2phm47a1JdFA/h5uH1WEC5SeeDdl5zGoIl+Ka7kSivW5sDT+Foplxl8QO0/LgE15yQH0
         WI7PlyYWO81LPjrwAPOvMUh8J+EcbbEzfIT8tt3HpY1ZpJ7NE6+7swAm8+Lv57A+KOnh
         U6Fg==
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=f6V+Xi9Tz7IoNS9KlYMNmyF7inZbs3RevEd1dHEtEkE=;
        b=TkS+/vm7AK+FOMbJuY3fTbfiZbsPqAsrsXoPtR8o5F4COKAmMUc/hIcvN34F2zP+YY
         VWdgT8bby1dTyxPwBbRjm5gnOt37CLEkAamLTfqx/9tcvk9nVhuQmttf+OQ5hsgw4E6A
         kjcljQJriqTICWXjjmD9W9mlHd/A7W2vEHtIutmG2xSi1GsHHNfdc4nZ55xoq1aAwl5F
         2WUQUFuKE1lgmII4COi4Qc8fykSn4Qv40HqSckHONk0/hRD8dC7/JQQFfUUvtlI6ONOG
         FjLcTUGXfm8dd4gmmMj5jm7rkWrzmuSUVBOUjGl7YjhoD1nYXx2bsGQmlfDXJ1caSTQY
         xk3Q==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=neutral (google.com: 108.166.43.67 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=f6V+Xi9Tz7IoNS9KlYMNmyF7inZbs3RevEd1dHEtEkE=;
        b=dLBgZlsrOpW9z3yPwKHGz82ywNnxzgV4fe+Hl768HiPfb5Ky13jFCgCp3preP8URwB
         xKx6fmC1qJ7u7rYl/yQVQqb7JN8Rfc1NWL2ovx7a3Y9NOhC9u/6J5lSKNdoWO6g4Tbo5
         AxUsAw+3HAJl7v+Lfg+pppvlWuNZbZq5tctIuJNcuuYh//fxtPsNThHROeRpvqG1tA/s
         Bwa4Bj3OTU4tcV84+tYmCDpIuG9lcrzrrZA1wYRcbtBnDpAToIqK6qhXTw1euyftdeRK
         CObzASlv1R7yKZmnGBfW8gRegJWldL/xJXBh4XFL5SxcwYX1HbJPai9G0IoktWTGCktQ
         fX1Q==
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=f6V+Xi9Tz7IoNS9KlYMNmyF7inZbs3RevEd1dHEtEkE=;
        b=hTHy4UtluNzSAF6gTbt32hymN+zPqPREmNAKeHUU2P+gNZ5UF1uqI8YduTo0Ym5KNd
         OU8APNy0JJmukaQPIoflXBVNVaxM0hqUkGI/4QPNZ0kJY2uUGBzHFRVebwS/Q0z5NI2s
         zHFn5515nD4pwQn4wHMkKiBeP7DvngN44YUW01YLrAoWww7Tk4Hud2/BG35ms/e9uqYQ
         1ro3w/F2tzGPevWOHYJnP1k4vovHEWAmDLpg0+lQOl4BJmiIzGrlb0hMpCg031zxR4bO
         nCYbpS4QNlzNb9Mlds9hUhFueOH0dICAcazTxAS2Jo+bM/jmJvNBkZO7uL6c6ok3CE6c
         4OiQ==
X-Gm-Message-State: AODbwcCXv8aohko72ZLGGpUX4hPdFoXYPI06oA56KDufG2QxcaNxmjm1
	2W4fY7CtWGeySA==
X-Received: by 10.36.105.21 with SMTP id e21mr4731837itc.19.1494954074128;
        Tue, 16 May 2017 10:01:14 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.156.8 with SMTP id f8ls647657ioe.14.gmail; Tue, 16 May
 2017 10:01:12 -0700 (PDT)
X-Received: by 10.107.14.195 with SMTP id 186mr11226872ioo.112.1494954072610;
        Tue, 16 May 2017 10:01:12 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1494954072; cv=none;
        d=google.com; s=arc-20160816;
        b=hum77Xy7lyzxhOtlejZWkMP+FW72zm96xF55ApE7lEibWnQ+hExVViA+8QHl7P65xs
         mEW4HZgRDR8a1eg9CFDVd7AJx38vx0G/q6X7OvprX9A+PF9GqHkAHm9SxSLoaXRMz2q9
         FgVCfOD1UH+iM0dNXJy8GpuZDn7Pa94KWRoWQYuMgR7sFXzxt6c8WJvHLiUhsMP4hJWO
         DYKaYOm0xNrPKrZhhwINns6WZ993tq82/mHhq49xs+IPhdWuEFbXGLYUgxlT/3cuPI80
         4iyyoXwch/kn707aLb4/A3GH0nHnSM/+0lOkmiBiy0P2QJ6X4fn9SBxwGJm/qbfm6DgN
         mUGA==
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=4sy6fc2Nt2HCH63qglz/3SugSaf4RkATc92tu9cktKY=;
        b=QLA+GwI9P6ZBOjAmT/zD6XFqBy+/L01OzoHdj1dgZ7j/wi+K5jpHzjbqXc3ePYRj54
         QXMpDRSfhrF/Al/APNLP2ySw+hQctc+NuNVnoClZPX9nNVqMCaAbfOS84/c2lPxprfW9
         rdZmWKf8cryc3KtThXOJCMdO+IKXbzSD+Eo+nEJOFn3G68pDjRwCEv/YnDDpJ8z97bT7
         0j6MpTGp+TaD5gE7omJ2ycR6HCEIdxclgtdnx+vCiHdlO2fMSu/EUVvofQARn3fLhZQg
         oBEXPG7CYxsLvz7m3yDC8ENV2lApsrbs6dFgXzixIr0+OYyFrNqqZvCUFYClQ0zHAe68
         wjxA==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: 108.166.43.67 is neither permitted nor denied by best guess record for domain of tom@honermann.net) smtp.mailfrom=tom@honermann.net
Original-Received: from smtp67.ord1c.emailsrvr.com (smtp67.ord1c.emailsrvr.com. [108.166.43.67])
        by mx.google.com with ESMTPS id n11si2528295ith.112.2017.05.16.10.01.12
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 16 May 2017 10:01:12 -0700 (PDT)
Received-SPF: neutral (google.com: 108.166.43.67 is neither permitted nor denied by best guess record for domain of tom@honermann.net) client-ip=108.166.43.67;
Original-Received: from smtp25.relay.ord1c.emailsrvr.com (localhost [127.0.0.1])
	by smtp25.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 2BD282059B
	for <std-proposals@isocpp.org>; Tue, 16 May 2017 13:01:12 -0400 (EDT)
X-Auth-ID: tom@honermann.net
Original-Received: by smtp25.relay.ord1c.emailsrvr.com (Authenticated sender: tom-AT-honermann.net) with ESMTPSA id 014B720597
	for <std-proposals@isocpp.org>; Tue, 16 May 2017 13:01:11 -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 13:01:12 -0400
In-Reply-To: <20170516164245.GA16348@fukushima.lysator.liu.se>
X-Original-Sender: tom@honermann.net
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 108.166.43.67 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:32491
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32491>

On 05/16/2017 12:42 PM, Magnus Fromreide wrote:
> On Tue, May 16, 2017 at 12:36:52PM -0400, Tom Honermann wrote:
>> On 05/16/2017 11:30 AM, Ville Voutilainen wrote:
>>> On 16 May 2017 at 18:25, Tom Honermann <tom@honermann.net> wrote:
>>>>>>            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};
>>>>>>        }
>>>>> Well, with the idea I cobbled together, I can write
>>>>>
>>>>> auto [x, =k->Key] = parseKey();
>>>>>
>>>>> and it means something completely different, because -> is a member
>>>>> access operator. So we can safely
>>>>> assume that k is an entity that supports operator->, and my binding
>>>>> there assigns to k->Key. It's such fun
>>>>> to try to extend a language where all good syntaxes have been taken a
>>>>> long time ago. :)
>>>>>
>>>> Oh, well, the solution to that is, of course, keyword spackling.
>>>>
>>>> auto [x, =k-> typename Key] = parseKey();
>>>>
>>>> :)
>>> What makes you think Key is a typename? :P
>>>
>> Because when I wrote that, I was intending to write a type constraint and
>> not a member access.  You can tell because I put 'typename' there :P
>>
>> Also because 'Key' starts with an uppercase letter but isn't all upper case
>> letters.  As we all know, that means it unambiguously designates a type.
>>
>> Actually, a type constraint doesn't makes much sense for an assignment
>> binding, and a member access doesn't make much sense for a structured
>> binding, so perhaps there is no ambiguity after all.
>>
>> auto [x -> SomeType, =k->Key] = parseKey();  // Constrains 'x' to 'SomeType', assigns 'k->Key'
>>
>> Yes, there is a certain amount of ick factor there.
> But why invent a new way to declare/constrain types that is almost unheard
> about?
This actually isn't a new way; it comes from the Concepts TS.
>
> What is wrong with the good old way?
>
> auto [SomeType x, =k->Key] = parseKey();

There is the question of what happens if the decomposed type of the 
matching element is not reference compatible with type 'SomeType'. 
Ill-formed?  Does 'x' change from being a structured binding to a 
variable of the declared type?  If so, are conversions performed? What 
type is decltype(x) and does it depend on the type of the matching 
element?  A syntax that indicates a type constraint (which is, I think, 
what is desired regardless of the syntax used) rather than a variable 
declaration avoids these questions.

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/ffcb4ca3-5fb8-41b4-8b38-cfd287148cd5%40honermann.net.

.
