From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.222.36 with SMTP id s34mr4560318yhp.24.1402586500086; Thu, 12 Jun 2014 08:21:40 -0700 (PDT) X-Received: by 10.50.73.196 with SMTP id n4mr130762igv.14.1402586499678; Thu, 12 Jun 2014 08:21:39 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!i13no73025qae.1!news-out.google.com!gi6ni1igc.0!nntp.google.com!a13no331595igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 12 Jun 2014 08:21:39 -0700 (PDT) In-Reply-To: <$ql0lCCpEcmTFwCt@ada-augusta.demon.co.uk> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <$ql0lCCpEcmTFwCt@ada-augusta.demon.co.uk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5c5d9f4a-cfcd-47ec-bd96-29e0e02bf32d@googlegroups.com> Subject: Re: A question about private types From: Adam Beneschan Injection-Date: Thu, 12 Jun 2014 15:21:39 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 2862 Xref: number.nntp.dca.giganews.com comp.lang.ada:186863 Date: 2014-06-12T08:21:39-07:00 List-Id: On Thursday, June 12, 2014 8:03:05 AM UTC-7, Mike H wrote: > ... Or, at lest, I expect the answer to be about private types. > My instinct is that the package below is vulnerable to erroneous use > because the "Address" component of "Cell_type" can be changed. I suspect > that this vulnerability could be removed if "Grid_index_type" is made > read only. I have attempted to make it a private type but it then > becomes non-discrete and can no longer be used as a parameter in > functions such as "Line_of". >=20 > Help please! And, preferably, in a form where the new source code is > sufficiently transparent to be understood when doing a "walk-through" > with a C++ speaker. If you want to prevent clients from modifying the "Address" of a Cell_Type,= the answer is to make Cell_Type (not Grid_Index_Type) private, and add pro= cedures/functions for retrieving the fields from Cell_Type that you want to= give them permission to retrieve, and for setting the fields that you want= to give them permission to set. By the way, I don't understand this: =20 > I have attempted to make [Grid_Index_Type] a private type but it then=20 > becomes non-discrete and can no longer be used as a parameter in=20 > functions such as "Line_of". Making Grid_Index_Type private would cause problems for your Grid_Type defi= nition (although you might be able to use Ada 2012's user-defined indexing = features to get around it). But why would Grid_Index_Type no longer be usa= ble as a parameter to Line_Of? I'm asking this just in case you have some = misunderstanding about the language that needs to be corrected. -- Adam