220 26534 <CAFk2RUaAW+xPzW5ov85qD0m9Dv6nikHZd0asUG7=2rinv3navg@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Adding a const qualifier to class access modifiers
Date: Mon, 4 Jul 2016 12:52:41 +0300
Lines: 59
Approved: news@gmane.org
Message-ID: <CAFk2RUaAW+xPzW5ov85qD0m9Dv6nikHZd0asUG7=2rinv3navg@mail.gmail.com>
References: <7145a8aa-6a74-4ff3-8984-4a74aef66b5d@isocpp.org> <20160704042756.GA19918@noemi>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1467625966 15470 80.91.229.3 (4 Jul 2016 09:52:46 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 4 Jul 2016 09:52:46 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5JHI7A7ALRB2XD5C5QKGQENRERKVA@isocpp.org Mon Jul 04 11:52:46 2016
Return-path: <std-proposals+bncBC5JHI7A7ALRB2XD5C5QKGQENRERKVA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f69.google.com ([209.85.213.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRB2XD5C5QKGQENRERKVA@isocpp.org>)
	id 1bK0YX-0001Au-3Q
	for gclcip-std-proposals@m.gmane.org; Mon, 04 Jul 2016 11:52:45 +0200
Original-Received: by mail-vk0-f69.google.com with SMTP id v6sf440144928vkb.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 04 Jul 2016 02:52:44 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :content-transfer-encoding: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=jrJg/iASmF75UQWVt3Yd4Te8HUskPG7byiZKF+EEIQU=;
        b=rcU0AxvRby4/pgndcyvlknNvHdSs41aio9MWZyPrI3oVFddV6w3iEQBbwFdf5QXMyj
         28x2/u7YmmJwXTLidytw7L91BqkopMzEuBdwM942cflQe+wV81lreesF8VJpPRsrqovf
         8uKjKfV7kggnqYKUGt/v7++rk1YmJSZTK6NRtdI66Bo/c6QumICHDqwBHMjdy04b5JYo
         O0NnMFIO7T7FLfh4C1y7aZyXDWmOUimflitxcdRvhurJifa+aeSBuBIf5qqyuMFfQ6xe
         Zk/vsOARuMWJIbRcTatINvmNLKpWH/RgiaUzYvDhWS3awK9imIxIuTr5Hm+LZGDPRWCq
         J9Lw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:content-transfer-encoding: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=jrJg/iASmF75UQWVt3Yd4Te8HUskPG7byiZKF+EEIQU=;
        b=DDsDzecApkBv3msvxiYgXwzKcK0ObRDCWTDCEFm0VOny85iMBmpwYE/ATVB/DkEKhg
         7M5J+ESF+dpP8GdoSkBcQcFrvZwOfs9vd9jpdWNhoH6AxLlHba2IQLIMN7z6DeE3as5M
         fjqfnnhVLtnrdw7DNMK9cmAO78n64mjgNxPtKWkIf9EH57QrM6SSxoB54+50EAG9D3rG
         J1XLeUia7vcvCeUdPEe2sZbkqjmYg50Q4joQTpxPoxYSitIhcyDURBEw4urKBfgh45fs
         Amgcyh849yqgmtjD0sbeIvU8ApHvpR1nfV3GDYZKb3WskwWVSLeSg/5yE9kIZYgjoSdB
         YP2 
X-Gm-Message-State: ALyK8tKgI1Sae0uF4XDL5P5SthLdjBwlfaT+N+Ns/jODRH+N/xrltWdNMWODYt4e6J2O5A==
X-Received: by 10.200.42.242 with SMTP id c47mr29743818qta.22.1467625963786;
        Mon, 04 Jul 2016 02:52:43 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.32.209 with SMTP id g200ls1395103iog.65.gmail; Mon, 04 Jul
 2016 02:52:42 -0700 (PDT)
X-Received: by 10.176.4.49 with SMTP id 46mr3824945uav.32.1467625962364;
        Mon, 04 Jul 2016 02:52:42 -0700 (PDT)
Original-Received: from mail-vk0-x22c.google.com (mail-vk0-x22c.google.com. [2607:f8b0:400c:c05::22c])
        by mx.google.com with ESMTPS id f97si920842vki.88.2016.07.04.02.52.42
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 04 Jul 2016 02:52:42 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400c:c05::22c as permitted sender) client-ip=2607:f8b0:400c:c05::22c;
Original-Received: by mail-vk0-x22c.google.com with SMTP id i63so55516569vkb.2
        for <std-proposals@isocpp.org>; Mon, 04 Jul 2016 02:52:42 -0700 (PDT)
X-Received: by 10.176.66.98 with SMTP id i89mr3816295uai.149.1467625961983;
 Mon, 04 Jul 2016 02:52:41 -0700 (PDT)
Original-Received: by 10.103.64.83 with HTTP; Mon, 4 Jul 2016 02:52:41 -0700 (PDT)
In-Reply-To: <20160704042756.GA19918@noemi>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 ville.voutilainen@gmail.com designates 2607:f8b0:400c:c05::22c as permitted
 sender) smtp.mailfrom=ville.voutilainen@gmail.com;       dmarc=pass (p=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-Spam-Checked-In-Group: 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:26534
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26534>

On 4 July 2016 at 07:27, Magnus Fromreide <magfr@lysator.liu.se> wrote:
> On Sun, Jul 03, 2016 at 06:25:42PM -0700, =C3=93lafur Waage wrote:
>> One of the biggest things I have seen in developing medium to large scal=
e
>> systems is how useful const is to show the original author's intent, tha=
t
>> this value should not be changed, even by grabbing a mutable variable an=
d
>> creating a const auto& temporary and using that temporary to state that
>> this value should stay the same.
>>
>> This get's tricky when dealing with class members, especially when
>> accessing them from the outside.
>>
>> Should you limit access via private and provide a Get function?
>> - Writing all those Get type functions can get tiring and bloats the cla=
ss
>> with very trivial functions, even if they return a copy or a const ref.
>>
>> Should you keep it public and take the python stance of "we're all adult=
s
>> here"?
>> - Opening the access to anyone outside can later down the line introduce
>> errors if it's a value that needs to be updated in a certain way to keep
>> the internal state of the class sane.
>
> The usual reply to this question is neither.
>
> What you should do is move the logic that need to access the value into
> methods of the class so that the class becomes more self contained.
> Yes, I am aware of this beeing harder to but the resulting system is gene=
rally
> easier to understand since there is less coupling between different class=
es.


With NDSMIs, this is what I'd do:

class X
{
    string data;
public:
    const string& cdata =3D data;
};

I don't think the suggested problem is so common that we need to
invent a new kind of an access specifier
to cater for it.

--=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/CAFk2RUaAW%2BxPzW5ov85qD0m9Dv6nikHZd0asUG7%3D2ri=
nv3navg%40mail.gmail.com.

.
