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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4ac6c27957bfd114 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!zen.net.uk!dedekind.zen.co.uk!peer.news.zetnet.net!newsfeed.uk.prserv.net!prserv.net!news.freedom2surf.net!not-for-mail From: Simon Smith Newsgroups: comp.lang.ada Subject: Re: What is the point of Private? Date: Sun, 01 May 2005 23:57:21 +0100 Organization: freedom2surf Message-ID: References: NNTP-Posting-Host: i-195-137-62-42.freedom2surf.net Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.freedom2surf.net 1114988169 4476 195.137.62.42 (1 May 2005 22:56:09 GMT) X-Complaints-To: abuse@freedom2surf.net NNTP-Posting-Date: Sun, 1 May 2005 22:56:09 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:10861 Date: 2005-05-01T23:57:21+01:00 List-Id: thanks for all the replies. All beginning to make sense now :-) chris wrote: > It's there for two reasons. It hides the implementation from clients of > the code and makes the compilers job easier. The decision seems to be > that the compiler should be able to determine how much space something > will take at compile time*. This means they had to put the > representation in the spec, so the compiler knew what to allocate. > > The alternatives are to leave everything public or to put the > representation in the body. Making everything public means someone can > adversely manipulate the contents of your data structures. They can > break the rules, and mess up the software. Completely hiding the > representation by putting it in the body has a different trade off. On > the one hand, you can substitute any representation by changing the body > alone, but on the other hand the compiler won't know how big the data > structure is and it has to treat all things the same way (by wrapping or > boxing them up - which has a cost). > > It's a trade off. The Ada people chose to put it in the spec because it > simplified the compiler, and it best suited their over all goals. Other > languages allow you to completely hide the representation in the > implementation. e.g. SML, Ocaml. Some make it public. > >> Why is it there? I am sure I have heard talk that its to stop the >> client from seeing exactly how the data is stored/manipulated however >> if people really did want to know this wouldn't they just scroll down >> the ada spec file and find out for themselves or am I missing >> something here? > > > Client code can't do that though. This means someone who uses the > compiled package can't see how it's implemented, but the maintainer can. > > > > Chris > > *There are probably other reasons too, I don't know what they are though.