220 28522 <201610051300.02280.marc.mutz@kdab.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Marc Mutz <marc.mutz@kdab.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A plea to reconsider adding Structured Bindings
 to language
Date: Wed, 5 Oct 2016 13:00:02 +0200
Organization: KDAB
Lines: 44
Approved: news@gmane.org
Message-ID: <201610051300.02280.marc.mutz@kdab.com>
References: <201610051238.17863.marc.mutz@kdab.com> <CAFk2RUYZDrLfm7QJtTiGEOdV52K3Kvv1ZdeKvoUfd2U2Ns32MA@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"
Content-Transfer-Encoding: 7bit
X-Trace: blaine.gmane.org 1475665106 7561 195.159.176.226 (5 Oct 2016 10:58:26 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 5 Oct 2016 10:58:26 +0000 (UTC)
Cc: Ville Voutilainen <ville.voutilainen@gmail.com>,
 Herb Sutter <hsutter@microsoft.com>,
 Bjarne Stroustrup <bjarne@stroustrup.com>,
 Gabriel Dos Reis <gdr@microsoft.com>
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCRPXDOU7ECRBQ5Z2O7QKGQESKX2U7A@isocpp.org Wed Oct 05 12:58:22 2016
Return-path: <std-proposals+bncBCRPXDOU7ECRBQ5Z2O7QKGQESKX2U7A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f72.google.com ([209.85.220.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCRPXDOU7ECRBQ5Z2O7QKGQESKX2U7A@isocpp.org>)
	id 1brjtq-0008N1-0V
	for gclcip-std-proposals@m.gmane.org; Wed, 05 Oct 2016 12:58:10 +0200
Original-Received: by mail-pa0-f72.google.com with SMTP id bv10sf441805013pad.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 05 Oct 2016 03:58:12 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:sender:from:organization:to:subject:date:cc
         :references:in-reply-to:mime-version:content-transfer-encoding
         :message-id: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=SmDiSSjbFO3/JoHJ0NISag45To9vpSJNL1oWDhh2ecU=;
        b=mzV6x1VF8cGbNOh0RrwK9mUizHKL8M90JBxteheEL5h6R2TobpwvIj4zNh6QSDgmLU
         aaDhxr6k859czjK2ZNv4PG6Gqw5u5jppXKRMKZAS9ovir9KeEKNBipyjnk+8sV26IfQf
         yNZeIgIYrZ8JEr98H5fQgVu4tKlWqn9BXskUe8QJI8LVJkqgmLEdVT9ax9oCV/y8fpNE
         FO1E86fdyPbBapnmGRBw1/6DpVx0+b0nC4+AWGmyYxaJJpvhFTA25jBOKae4zmbaarcy
         7o2qzHal2xXIX/gTK+LRLgPIuM+N63Cr84lzp/dtGRUonym/eKGkhnA3CD 
X-Gm-Message-State: AA6/9RnYX9Kg35qFVdjih6DvJTibUfygn0yR8wgCqFs/ErByueJF59QlLziqI/DUKWwaXg==
X-Received: by 10.98.23.147 with SMTP id 141mr816562pfx.41.1475665091745;
        Wed, 05 Oct 2016 03:58:11 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.15.105 with SMTP id 96ls373141ott.41.gmail; Wed, 05 Oct
 2016 03:58:11 -0700 (PDT)
X-Received: by 10.37.17.6 with SMTP id 6mr6385799ybr.148.1475665091016;
        Wed, 05 Oct 2016 03:58:11 -0700 (PDT)
Original-Received: from mail.kdab.com (mail.kdab.com. [176.9.126.58])
        by mx.google.com with ESMTPS id e142si5411284ywa.11.2016.10.05.03.58.10
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 05 Oct 2016 03:58:10 -0700 (PDT)
Received-SPF: pass (google.com: domain of marc.mutz@kdab.com designates 176.9.126.58 as permitted sender) client-ip=176.9.126.58;
X-Virus-Scanned: amavisd-new at kdab.com
Original-Sender: marc@kdab.com
In-Reply-To: <CAFk2RUYZDrLfm7QJtTiGEOdV52K3Kvv1ZdeKvoUfd2U2Ns32MA@mail.gmail.com>
X-Original-Sender: marc.mutz@kdab.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of marc.mutz@kdab.com designates 176.9.126.58 as permitted sender) smtp.mailfrom=marc.mutz@kdab.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:28522
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28522>

On Wednesday 05 October 2016 12:40:38 Ville Voutilainen wrote:
> On 5 October 2016 at 13:38, Marc Mutz <marc.mutz@kdab.com> wrote:
> > In conjunction with auto deduction, the caller choosing the names means
> > that the code becomes brittle in the face of changes to the return type,
> > e.g. when reordering fields to fill padding holes.
> 
> There have been discussions about that, especially about fields change
> their types.

And? What was the outcome?

> > Structured Bindings would be acceptable if, like scripting languages, we
> > didn't have anything else to work with.
> > 
> > But we do: We can return a struct.
> 
> Structured bindings work with structs as well. If you think structured
> bindings mean
> you must return a tuple, you're mistaken.

Yes, I know that. But if I return a struct with proper names, I don't need SB 
to handle it. Indeed, it would be counter-productive to have to find names for 
SB if can access the names the implementor chose with C-space in my IDE from 
the auto variable that stores the return type.

> > I fear Structured Bindings will lead to an explosion of *really* bad API
> > that returns std::pair or std::tuple when it should return a small
> > struct with
> 
> C++ programmers are not idiots.

C++ programmers are humans, though.

We all make mistakes. Even Alex Stepanov did. The art is to not repeat them.

Thanks,
Marc

-- 
Marc Mutz <marc.mutz@kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - Qt, C++ and OpenGL Experts

.
