220 19931 <55D4CD4A.8070803@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Andrey Semashev <andrey.semashev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: default arguments
Date: Wed, 19 Aug 2015 21:39:06 +0300
Lines: 42
Approved: news@gmane.org
Message-ID: <55D4CD4A.8070803@gmail.com>
References: <ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org>
 <CANh8DEnn-PWZRNUvqhjcaJpiZk+6hyxVpy5qQXgTUw-uMhdh1A@mail.gmail.com>
 <ccf43684-c479-420e-a6b2-5a23673f7c5a@isocpp.org>
 <89bf9d09-00ed-45db-bf88-39c844707bd1@isocpp.org>
 <b003ffb3-2f0b-4c41-8db0-0a57743e5d93@isocpp.org>
 <CAD6_Qj9xzNThT7wX+LN-Rqe7CNys7s4jr==gzRoirOxCWefGwQ@mail.gmail.com>
 <87b15f40-b36a-47bd-b822-8df53dd72287@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
X-Trace: ger.gmane.org 1440009570 6946 80.91.229.3 (19 Aug 2015 18:39:30 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 19 Aug 2015 18:39:30 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXY5TXHWYJRBTM22OXAKGQEFYAX6EI@isocpp.org Wed Aug 19 20:39:25 2015
Return-path: <std-proposals+bncBCXY5TXHWYJRBTM22OXAKGQEFYAX6EI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wi0-f199.google.com ([209.85.212.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXY5TXHWYJRBTM22OXAKGQEFYAX6EI@isocpp.org>)
	id 1ZS8GU-0005UI-9n
	for gclcip-std-proposals@m.gmane.org; Wed, 19 Aug 2015 20:39:10 +0200
Original-Received: by wilj18 with SMTP id j18sf5129486wil.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 19 Aug 2015 11:39:09 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-type: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=SgJOowQ0iNPLzbv58xV23T+bMKIZLNDpxY8ZNAqsYaY=;
        b=iFr4tACIAxX1oUbVxEyOBHfwpi3n6gJF57kHJvPYbBgaIZJoXexB6fM6CdV3KopaHv
         bheMJ+m4/drR07sgYs2H8Zhpyv48nwwVv5HIZ0QAYZM5h3I3cKeQnn4OSiezxtj1HyIV
         jRRQR5PMEF/TfFdFAo3aAPLFNpkNWApeB4HpkJZ8RIyJF1wMM3kjp2DP5hIk2pEOR7mD
         dsucHb333uOh0aZb+gezKcK6d4xz1iD6MQxDi3op3a3emKdQ3oiKS460LHyghLjQPmur
         bWQnfkznZAzV6J90PDhrPHdKffAAxsXejYZQbwIjUzpqrIeVAqt5kN0pnPC5v2HdONYA
         Gqew= 
X-Gm-Message-State: ALoCoQlfUldP6MQEMYSWekJdVEx1ktArHWm6sxmmTuDkgnABPfRnLTfGuXkYE0bRW8IpSHmkx7c5
X-Received: by 10.112.17.106 with SMTP id n10mr2339690lbd.18.1440009549756;
        Wed, 19 Aug 2015 11:39:09 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.121.38 with SMTP id lh6ls52240lab.47.gmail; Wed, 19 Aug
 2015 11:39:08 -0700 (PDT)
X-Received: by 10.152.206.73 with SMTP id lm9mr1542294lac.0.1440009548505;
        Wed, 19 Aug 2015 11:39:08 -0700 (PDT)
Original-Received: from mail-la0-x235.google.com (mail-la0-x235.google.com. [2a00:1450:4010:c03::235])
        by mx.google.com with ESMTPS id d10si1461621lae.52.2015.08.19.11.39.08
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 19 Aug 2015 11:39:08 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrey.semashev@gmail.com designates 2a00:1450:4010:c03::235 as permitted sender) client-ip=2a00:1450:4010:c03::235;
Original-Received: by lagz9 with SMTP id z9so8591706lag.3
        for <std-proposals@isocpp.org>; Wed, 19 Aug 2015 11:39:08 -0700 (PDT)
X-Received: by 10.112.77.10 with SMTP id o10mr12955399lbw.73.1440009547894;
        Wed, 19 Aug 2015 11:39:07 -0700 (PDT)
Original-Received: from [192.168.1.2] (broadband-178-140-129-233.nationalcablenetworks.ru. [178.140.129.233])
        by smtp.googlemail.com with ESMTPSA id tj8sm443756lbb.22.2015.08.19.11.39.06
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 19 Aug 2015 11:39:06 -0700 (PDT)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.2.0
In-Reply-To: <87b15f40-b36a-47bd-b822-8df53dd72287@isocpp.org>
X-Original-Sender: andrey.semashev@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrey.semashev@gmail.com designates 2a00:1450:4010:c03::235 as
 permitted sender) smtp.mailfrom=andrey.semashev@gmail.com;       dkim=pass
 header.i=@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:19931
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19931>

On 19.08.2015 21:07, Arthur Tchaikovsky wrote:
> Not all members in struct are public. From elementary school, everyone
> knows that struct differs from class that *by default* members are
> public in struct and private in class. ;)
> That's why I see it as a violation of encapsulation.

I don't see the connection between the default access mode and 
encapsulation. Encapsulation is implementation hiding. It can be 
achieved by different means, including but not limited to member access 
management. Classes are no different from structs except for the default 
access mode - both can be used to achieve the same level of encapsulation.

And no, all-public structs do not violate encapsulation in general. For 
instance, std::pair - a struct with public data, does not break 
encapsulation of std::(unordered_)map.

> Secondly, not only
> structs should be concerned, but classes too. And not only
> initialization should be a concern here but also setting value *after*
> the object had been initialized. Taken all this above, I say that
> accessing members of a class/struct by names, be it during
> initialization or after that fact is violation of encapsulation and it
> should be discouraged in modern C++. This kind of code may very well be
> OK for C but C++ is not C.

I don't mean to sound harsh, but that's narrow minded thinking. The 'OOP 
everywhere' era has passed as people realized that it is not efficient 
in all scenarios. C-style structs are useful in some contexts and named 
member initialization is useful as well. See ffmpeg code for instance, 
the way codecs and formats are described. That's C, naturally, but 
imagine how much more code that would require in today's C++ with 
private members, constructors and default arguments. And then imagine 
how difficult it would be to modify the struct used as the descriptor.

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
