220 25691 <4a4c2fe7-397e-4ca0-bdbe-04e77f075cee@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: About subverting access rights
Date: Thu, 28 Apr 2016 11:48:44 -0700 (PDT)
Lines: 409
Approved: news@gmane.org
Message-ID: <4a4c2fe7-397e-4ca0-bdbe-04e77f075cee@isocpp.org>
References: <20e81af7-4506-4408-b73a-58371434bd40@isocpp.org>
 <de4ba8f4-55c3-417b-ab44-61e54596df4b@isocpp.org>
 <nflju1$sv4$1@ger.gmane.org>
 <CAFk2RUbarSOgFFy=BM3XLP6hvWqrCcxQxxPqoS1CcGZmSgRp7g@mail.gmail.com>
 <CA+fGSbMkr1W=hj8=2eSjHUGMYjgh=j7y2wnZ0JRgqrvPV85Qiw@mail.gmail.com>
 <CAFk2RUa7b5RLP8BM_E+=guCi9hpKTLU7u1CQo054y_CEzdcoZg@mail.gmail.com>
 <CA+fGSbO_K50BSu-g+Y76DeOSwdwATtc4DeHGB80z_mpgsCdgag@mail.gmail.com>
 <20160426021923.4898897.72532.10230@gmail.com>
 <CA+fGSbOkRpb1XZ1v2GTYn6bkDXY0A1JQ+MskuDou9C7hZpywGQ@mail.gmail.com>
 <472a15d5-4591-4bd1-9233-01c8550c5c6f@isocpp.org>
 <CA+fGSbMNRKoQCTsQtWmHXXMXV8qqC_KN3E-EApW6DKSDDW5GOw@mail.gmail.com>
 <2257513b-f4d8-44ed-8ccf-1da1ff1e4ac5@isocpp.org>
 <CANPtknxLtKDGP7ShScB33LoC_PxBBGPx=_jSo8kj9f_Z-42FxA@mail.gmail.com>
 <CA+fGSbNdikEoZ7TXz_9JS862Sa5ZL+UJC=VQBXOr0+Gpp4=1LA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_6238_147938797.1461869324789"
X-Trace: ger.gmane.org 1461869332 30541 80.91.229.3 (28 Apr 2016 18:48:52 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 28 Apr 2016 18:48:52 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBDVWRG4QKGQEMLNR4TY@isocpp.org Thu Apr 28 20:48:48 2016
Return-path: <std-proposals+bncBCEKFTV6ZUMBBDVWRG4QKGQEMLNR4TY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f69.google.com ([209.85.218.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBDVWRG4QKGQEMLNR4TY@isocpp.org>)
	id 1avqzX-00079W-SC
	for gclcip-std-proposals@m.gmane.org; Thu, 28 Apr 2016 20:48:48 +0200
Original-Received: by mail-oi0-f69.google.com with SMTP id y69sf165568379oif.0
        for <gclcip-std-proposals@m.gmane.org>; Thu, 28 Apr 2016 11:48:47 -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=NgrVSS4zeoQXMAUr6OkIlQ1a/At84Px46iTaET2fS5o=;
        b=w/cui7jR/ZlJMZkx6WZeexcFMobE64tdE1uyVg3770cd+oMTDhwm3SZzZwBiUP7El3
         EtJhE3is/AJQ51WYkr1hEb/gC8cPfCzt29l9Rj3yyJ6Zbl7olBx6Bte8518eX4LgCdtU
         tNDD7Sx3bOTTz3WRs6VTQw4BQfsRm0Y6r89vpX+CNcesaIcm+oCRhAcXU5U0nUxyA34m
         KaLyDw4IAZtYCv3DZ6FHSyUUlpaUJQbDkersWiK1MCj8jHKLh0q4EsZrxy5zUE/cl2lW
         BdDj+6ELR/hVMCW99S+mf+u0raleDx/wFi4E0JvpF3J9Jl4njuDDdkJxkak3WpAjKA2t
         wJFA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        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=NgrVSS4zeoQXMAUr6OkIlQ1a/At84Px46iTaET2fS5o=;
        b=gb/vd6fV/ZhxQGTzt1aPCKZPF1dXEN2fUXuvPa4QRwoYsZtJ6C5fJ8ekOg/6cBg9Fg
         XgZJ7puP5fDeRGQINUeZx14y9RGosEaspEzAnp6eogR/Axr5Yr6rAc3CrnjWntyv459K
         yGqTZwheEbEnmMIc4ZvV5afWtJ55KP5XkLUHbLyHHvnVf3kZJURgvkYQXHAW0klT2Wv2
         SpQGCK6jxyMG70UJBS9He+/sLBnWdvKxhAOWtdmPwwNvo1CDoSj8GV+lZ/TxUSGH2dQp
         B49ITc9bTr1ukg/+gwzeR5adwp44mbra8FsNXdB+bEWQdUMXgKIq6OKpm67I6RUR1FTV
         ZDnQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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=NgrVSS4zeoQXMAUr6OkIlQ1a/At84Px46iTaET2fS5o=;
        b=i7HDwqWjtzyfp6GNzVmeksnqjQpD0Xc3Vih6UrktAQsFO4TQKYY2XVe0gDW2dgoSWl
         IIjTgdk8Cuutar97hQxyp3hURWyZzUtuL8rFbDO8pbJqUHPPfRnG8VyBj25uI58bTrhB
         /1clnP09UiJLyEXE67ON1Mc14UVlJS0ct5+/58BrgL4omeqx4LNq1yQo61m1G7SRHnhD
         vXh8rImhAvPiAE8oyrEpvOSlUNS8ITKSo34CqkDOdv5Avmz1g+JK3qDi4kMOWa2QCNb+
         gvY2QsfgpdAgX+6dlGPC5ktNuB+K8eLNtk852e9WADWZ7QmKOPPzELgqygPW87Pm2os1
         P2IA==
X-Gm-Message-State: AOPr4FXJn/Y3fQWqPUn8twT5FhBoUr2+uMAJ2bH+ZZwC/seNQbsypUbWZgXUwtSHy9SzZw==
X-Received: by 10.50.29.77 with SMTP id i13mr15308585igh.11.1461869326841;
        Thu, 28 Apr 2016 11:48:46 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.128.135 with SMTP id no7ls17085igb.41.canary; Thu, 28 Apr
 2016 11:48:45 -0700 (PDT)
X-Received: by 10.50.30.38 with SMTP id p6mr742781igh.10.1461869325906;
        Thu, 28 Apr 2016 11:48:45 -0700 (PDT)
In-Reply-To: <CA+fGSbNdikEoZ7TXz_9JS862Sa5ZL+UJC=VQBXOr0+Gpp4=1LA@mail.gmail.com>
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-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:25691
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/25691>

------=_Part_6238_147938797.1461869324789
Content-Type: multipart/alternative; 
	boundary="----=_Part_6239_456387032.1461869324789"

------=_Part_6239_456387032.1461869324789
Content-Type: text/plain; charset=UTF-8

On Thursday, April 28, 2016 at 1:35:11 AM UTC-4, Ricardo Andrade wrote:
>
> Let me summarize the whole point of starting this discussion...
> - We cannot prevent people from circumventing encapsulation.
>

It depends on what you mean by that. As a practical matter on real 
implementations, you are correct.

As a matter of standard-sanctioned behavior, we very much can.

Something can be illegal, yet people will still do it. That fact alone does 
not mean the law should be changed to permit it.

- Reflection is likely to add yet another way to do it.
>

Quite likely.

- This will be the first "standard" way for this purpose.
>

Yes.

- It has the benefit of being easy to spot in the code (currently as 
> get_all_data_members in P0194R0).
>

Kinda. Yes, you can spot that someone is calling `get_all_data_members`, 
but knowing exactly which objects this is being employed upon will be much 
more difficult. Especially in a deeply-nested template function.

- But there's a chance it will be costly in terms of compile time and 
> complexity.
>

.... I suppose that's possible. I mean, I don't know of a way to iterate 
through the unknown privates of a type at compile time that *wouldn't* 
involve template metaprogramming. But it's possible you could craft such a 
mechanism, and therefore it would be faster at compile time than reflection.

- People may end up not using it and sticking with the old "non-standard" 
> ways
>

That's a good thing. We do not want people to use reflection for the 
specific purpose of violating access controls.

- In the other hand, if people do use it, reflection gets the bad 
> reputation of being "the corner of the language reserved for evil" - as it 
> does in the other languages.
>

Wait, what? How does that logically follow? You just claimed that people 
won't use reflection to violate access controls because it's slow. If 
that's true, why would it gain this bad reputation you speak of?

So either this statement or the one before it is false. Or both. But they 
can't both be true.

Oh, and do you have any basis for the claim that reflection in other 
languages is seen as "the corner of the language reserved for evil"? I was 
under the impression that reflection in C# was used fairly heavily by XAML, 
for example. I did a quick search for "C# reflection evil", and the most I 
got were warnings about the *performance* of reflecting, not the concept 
itself.

So it seems that in other languages, there is not such a rash of people 
using reflection to violate encapsulation that people consider reflection a 
priori perfidious.
 

> - Now that you mentioned accidents, get_all_data_members vs. 
> get_data_members don't contribute much to prevent those, but there's still 
> time to work that out - I'll mentioned that to the author of P0194R0.
>
> That said, comes the question:
> Wouldn't be better to provide a "reinterpret_cast"-like mechanism (or 
> anything else) just for this purpose?
>

No. We don't want to regularize bad behavior. And violating encapsulation 
is *always* bad behavior.

FYI: `reinterpret_cast` is not regularizing bad behavior; it's simply a 
tool that can be easily abused.

- Reflection would be the "mechanism to list declarations and infer their 
> characteristics", the way to use them that's up to you.
>

That's not what reflection is. Reflection also allows you to call methods, 
access data members, and so forth. And in any case, if reflection allows 
violation of access controls, it must still do so even with whatever other 
method you want to add.

- It would be easy and obvious to find such violations in the code. Then 
> violators can be caught.
>

Only if they are used consistently.

- If a proposed solution has equivalent performance of the hacky 
> alternatives but it states clearly the intentions, people will prefer to 
> use it (or they would be so ashamed of having such ideas and avoid it).
>

Only if they are writing new code. Old code isn't automatically going to be 
changed.

- A dedicated language solution is more likely to find a better balance for 
> safety, freedom and clarity than something buried deep down in reflection.
>

Reflection does not allow private access because it is attempting to 
improve "freedom" or "clarity" or whatever. It's doing it because 
reflection needs to in order to be a proper tool.

Also, your statement presupposes that the current "balance" is problematic. 
It isn't. Just because some people break laws doesn't make those laws wrong.

I bet there are several ideas that could work out but first we need to go 
> over this feeling that people will use whatever is proposed everyday and 
> break everything.
>

Sanctioning the violation of encapsulation is, and of a right ought to be, 
a hard sell.

Encapsulation should be a binary concept. Either it is accessible without 
perfidy or it is not. Saying that it isn't accessible unless you do this 
slightly inconvenient thing means that it is *accessible*. And therefore 
not encapsulated.
 

> People stay away from "reinterpret_cast" already
>

That's because they use C-style casts.
 

> because is too 'dark' and bet people would think twice before using 
> something called "violate_access_cast".
>
> That's it.
>
> On Wed, Apr 27, 2016 at 4:13 PM, Peter Koch Larsen <peter.ko...@gmail.com 
> <javascript:>> wrote:
>
>> I do not understand all this fuzz about subversion of access rights.
>> Let us face it:
>> *) The purpose of access privileges is to protect the programmer from
>> doing something stupid, such as using an
>>     object in a way it way not designed to be used. It has never been
>> the purpose of access privileges to e.g. protect
>>     a system from an intruder or something in that direction.
>> *) There are already ways in C++ to get access to the private parts of
>> an object. Having one more way to do so is not
>>    a problem.
>>
>
Neither of those is a justification for doing what you suggest.
 

> That being said, I believe that getting the access should be
>> difficult: it should be blatantly clear that you are doing
>> something dangerous - just as it is with e.g. reinterpret_cast.
>
>
`reinterpret_cast` is not "difficult".

Also,
>> I fail to see the advantage of having this access.
>> I am in the camp that believes that e.g. serialization is perfectly
>> feasible without knowledge of the inner details about
>> how such a class is defined.
>>
>
So... what you're telling me is that you want to write crappy, fragile 
code. You want to violate standard rules about data hiding based on a 
premise that has been *proven faulty* (all it takes is one counter-example 
and I provided it). Also, even if we allowed you private access, you still 
couldn't properly construct such objects, because the only way to start the 
lifetime of an object in a piece of memory is to use placement `new`. Which 
must call a constructor. So your prospective unintrusive serialization 
library still has to use extra-standard methods (an illegal cast to `T*` or 
`T&` at some point).

You are basically proving exactly why we *shouldn't* let you do what you 
want. Because if you give people a standard-sanctioned tool for breaking 
encapsulation, people like you will *misuse it*. Since you have clearly and 
unequivocally stated your intent to do so.

Really, the only thing you've convinced me of is that reflection should 
have *additional* controls, for the sole purpose of preventing people like 
you from writing the library you want to write. That there should be some 
mechanism to prevent `get_all_data_members` and its ilk from working unless 
you are in code that has private access already. Perhaps the MetaObject 
type generated for reflection purposes should have Public, Protected, and 
Private versions. If you're in code with private access to the class and 
you get a MetaObject for it, then you get the Private MetaObject type.

-- 
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/4a4c2fe7-397e-4ca0-bdbe-04e77f075cee%40isocpp.org.

------=_Part_6239_456387032.1461869324789
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Thursday, April 28, 2016 at 1:35:11 AM UTC-4, Ricardo A=
ndrade wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
Let me summarize the whole point of starting this discussion...<div>- We ca=
nnot prevent people from circumventing encapsulation.</div></div></blockquo=
te><div><br>It depends on what you mean by that. As a practical matter on r=
eal implementations, you are correct.<br><br>As a matter of standard-sancti=
oned behavior, we very much can.<br><br>Something can be illegal, yet peopl=
e will still do it. That fact alone does not mean the law should be changed=
 to permit it.<br><br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr"><div>- Reflection is likely to add yet another way to do it.=
</div></div></blockquote><div><br>Quite likely.<br><br></div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px =
#ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>- This will be the fir=
st &quot;standard&quot; way for this purpose.</div></div></blockquote><div>=
<br>Yes.<br><br></div><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"><div>- It has the benefit of being easy to spot in the code (curre=
ntly as get_all_data_members in P0194R0).</div></div></blockquote><div><br>=
Kinda. Yes, you can spot that someone is calling `get_all_data_members`, bu=
t knowing exactly which objects this is being employed upon will be much mo=
re difficult. Especially in a deeply-nested template function.<br><br></div=
><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>- But t=
here&#39;s a chance it will be costly in terms of compile time and complexi=
ty.</div></div></blockquote><div><br>... I suppose that&#39;s possible. I m=
ean, I don&#39;t know of a way to iterate through the unknown privates of a=
 type at compile time that <i>wouldn&#39;t</i> involve template metaprogram=
ming. But it&#39;s possible you could craft such a mechanism, and therefore=
 it would be faster at compile time than reflection.<br><br></div><blockquo=
te class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left:=
 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>- People may end =
up not using it and sticking with the old &quot;non-standard&quot; ways</di=
v></div></blockquote><div><br>That&#39;s a good thing. We do not want peopl=
e to use reflection for the specific purpose of violating access controls.<=
br><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div>- In the other hand, if people do use it, reflection gets the bad repu=
tation of being &quot;the corner of the language reserved for evil&quot; - =
as it does in the other languages.</div></div></blockquote><div><br>Wait, w=
hat? How does that logically follow? You just claimed that people won&#39;t=
 use reflection to violate access controls because it&#39;s slow. If that&#=
39;s true, why would it gain this bad reputation you speak of?<br><br>So ei=
ther this statement or the one before it is false. Or both. But they can&#3=
9;t both be true.<br></div><div><br>Oh, and do you have any basis for the c=
laim that reflection in other languages is seen as &quot;the corner of the =
language reserved for evil&quot;? I was under the impression that reflectio=
n in C# was used fairly heavily by XAML, for example. I did a quick search =
for &quot;C# reflection evil&quot;, and the most I got were warnings about =
the <i>performance</i> of reflecting, not the concept itself.<br><br>So it =
seems that in other languages, there is not such a rash of people using ref=
lection to violate encapsulation that people consider reflection a priori p=
erfidious.<br>=C2=A0</div><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"><div>- Now that you mentioned accidents, get_all_data_members =
vs. get_data_members don&#39;t contribute much to prevent those, but there&=
#39;s still time to work that out - I&#39;ll mentioned that to the author o=
f P0194R0.</div><div><br></div><div>That said, comes the question:</div><di=
v>Wouldn&#39;t be better to provide a &quot;reinterpret_cast&quot;-like mec=
hanism (or anything else) just for this purpose?</div></div></blockquote><d=
iv><br>No. We don&#39;t want to regularize bad behavior. And violating enca=
psulation is <i>always</i> bad behavior.<br><br>FYI: `reinterpret_cast` is =
not regularizing bad behavior; it&#39;s simply a tool that can be easily ab=
used.<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr"><div></div><div>- Reflection would be the &quot;mechanism to list dec=
larations and infer their characteristics&quot;, the way to use them that&#=
39;s up to you.</div></div></blockquote><div><br>That&#39;s not what reflec=
tion is. Reflection also allows you to call methods, access data members, a=
nd so forth. And in any case, if reflection allows violation of access cont=
rols, it must still do so even with whatever other method you want to add.<=
br><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div>- It would be easy and obvious to find such violations in the code. Th=
en violators can be caught.</div></div></blockquote><div><br>Only if they a=
re used consistently.<br><br></div><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"><div>- If a proposed solution has equivalent perform=
ance of the hacky alternatives but it states clearly the intentions, people=
 will prefer to use it (or they would be so ashamed of having such ideas an=
d avoid it).</div></div></blockquote><div><br>Only if they are writing new =
code. Old code isn&#39;t automatically going to be changed.<br><br></div><b=
lockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;borde=
r-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>- A dedica=
ted language solution is more likely to find a better balance for safety, f=
reedom and clarity than something buried deep down in reflection.</div></di=
v></blockquote><div><br>Reflection does not allow private access because it=
 is attempting to improve &quot;freedom&quot; or &quot;clarity&quot; or wha=
tever. It&#39;s doing it because reflection needs to in order to be a prope=
r tool.<br><br>Also, your statement presupposes that the current &quot;bala=
nce&quot; is problematic. It isn&#39;t. Just because some people break laws=
 doesn&#39;t make those laws wrong.<br><br></div><blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;"><div dir=3D"ltr"><div></div><div>I bet there are several=
 ideas that could work out but first we need to go over this feeling that p=
eople will use whatever is proposed everyday and break everything.</div></d=
iv></blockquote><div><br>Sanctioning the violation of encapsulation is, and=
 of a right ought to be, a hard sell.<br><br>Encapsulation should be a bina=
ry concept. Either it is accessible without perfidy or it is not. Saying th=
at it isn&#39;t accessible unless you do this slightly inconvenient thing m=
eans that it is <i>accessible</i>. And therefore not encapsulated.<br>=C2=
=A0</div><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"><div=
>People stay away from &quot;reinterpret_cast&quot; already</div></div></bl=
ockquote><div><br>That&#39;s because they use C-style casts.<br>=C2=A0</div=
><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div> becaus=
e is too &#39;dark&#39; and bet people would think twice before using somet=
hing called &quot;violate_access_cast&quot;.</div><div><br></div><div>That&=
#39;s it.<br></div><div><div><br><div class=3D"gmail_quote">On Wed, Apr 27,=
 2016 at 4:13 PM, Peter Koch Larsen <span dir=3D"ltr">&lt;<a href=3D"javasc=
ript:" target=3D"_blank" gdf-obfuscated-mailto=3D"pUbkQ_icCAAJ" rel=3D"nofo=
llow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclic=
k=3D"this.href=3D&#39;javascript:&#39;;return true;">peter.ko...@gmail.com<=
/a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);=
border-left-style:solid;padding-left:1ex">I do not understand all this fuzz=
 about subversion of access rights.<br>
Let us face it:<br>
*) The purpose of access privileges is to protect the programmer from<br>
doing something stupid, such as using an<br>
=C2=A0 =C2=A0 object in a way it way not designed to be used. It has never =
been<br>
the purpose of access privileges to e.g. protect<br>
=C2=A0 =C2=A0 a system from an intruder or something in that direction.<br>
*) There are already ways in C++ to get access to the private parts of<br>
an object. Having one more way to do so is not<br>
=C2=A0 =C2=A0a problem.<br></blockquote></div></div></div></div></blockquot=
e><div><br>Neither of those is a justification for doing what you suggest.<=
br>=C2=A0</div><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=
"><div><div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb=
(204,204,204);border-left-style:solid;padding-left:1ex">
That being said, I believe that getting the access should be<br>
difficult: it should be blatantly clear that you are doing<br>
something dangerous - just as it is with e.g. reinterpret_cast.</blockquote=
></div></div></div></div></blockquote><div><br>`reinterpret_cast` is not &q=
uot;difficult&quot;.<br><br></div><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"><div><div><div class=3D"gmail_quote"><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;=
border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex=
"> Also,<br>
I fail to see the advantage of having this access.<br>
I am in the camp that believes that e.g. serialization is perfectly<br>
feasible without knowledge of the inner details about<br>
how such a class is defined.<br></blockquote></div></div></div></div></bloc=
kquote><div><br>So... what you&#39;re telling me is that you want to write =
crappy, fragile code. You want to violate standard rules about data hiding =
based on a premise that has been <i>proven faulty</i> (all it takes is one =
counter-example and I provided it). Also, even if we allowed you private ac=
cess, you still couldn&#39;t properly construct such objects, because the o=
nly way to start the lifetime of an object in a piece of memory is to use p=
lacement `new`. Which must call a constructor. So your prospective unintrus=
ive serialization library still has to use extra-standard methods (an illeg=
al cast to `T*` or `T&amp;` at some point).<br><br>You are basically provin=
g exactly why we <i>shouldn&#39;t</i> let you do what you want. Because if =
you give people a standard-sanctioned tool for breaking encapsulation, peop=
le like you will <i>misuse it</i>. Since you have clearly and unequivocally=
 stated your intent to do so.<br><br>Really, the only thing you&#39;ve conv=
inced me of is that reflection should have <i>additional</i> controls, for =
the sole purpose of preventing people like you from writing the library you=
 want to write. That there should be some mechanism to prevent `get_all_dat=
a_members` and its ilk from working unless you are in code that has private=
 access already. Perhaps the MetaObject type generated for reflection purpo=
ses should have Public, Protected, and Private versions. If you&#39;re in c=
ode with private access to the class and you get a MetaObject for it, then =
you get the Private MetaObject type.<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/4a4c2fe7-397e-4ca0-bdbe-04e77f075cee%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4a4c2fe7-397e-4ca0-bdbe-04e77f075cee=
%40isocpp.org</a>.<br />

------=_Part_6239_456387032.1461869324789--
------=_Part_6238_147938797.1461869324789--

.
