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: a07f3367d7,46b760ffb623378c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!nwrddc01.gnilink.net.POSTED!c2bfcbcf!not-for-mail Subject: Re: Hiding the value of Constants From: "Ed Falis" Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 Newsgroups: comp.lang.ada References: <30696d63-16e8-44e2-a4a5-db5095d7cfec@m3g2000pri.googlegroups.com> <4a58e74a$0$30233$9b4e6d93@newsspool1.arcor-online.net> Content-Transfer-Encoding: 7bit Message-ID: User-Agent: Opera Mail/9.64 (Linux) Date: Sat, 11 Jul 2009 22:15:25 GMT NNTP-Posting-Host: 96.252.105.4 X-Complaints-To: abuse@verizon.net X-Trace: nwrddc01.gnilink.net 1247350525 96.252.105.4 (Sat, 11 Jul 2009 18:15:25 EDT) NNTP-Posting-Date: Sat, 11 Jul 2009 18:15:25 EDT Xref: g2news2.google.com comp.lang.ada:7005 Date: 2009-07-11T22:15:25+00:00 List-Id: On Sat, 11 Jul 2009 17:53:15 -0400, anon wrote: > In the years, there has been a few people asking how to hide values or > constant. > Some say use private which the value is still known. Others say use > functions > which can be hidden by removing the source code of the body of the > package, > but requires a call runtime routine each time the value is needed. > > But the main problem is that each person who wants to hide a constant > forgets > is that all someone has to do is to write a simple program to print the > value. > So, except to may be getting bonus points from a prof, its a waste of > time. > > In my example I just showed a third way. To initialize the value at the > Elaboration time instead of compile or using main runtime. > > You need to spead your weekends learning a few ticks of the trade about > Ada. > The program works. Just play with it, you might learn that using > functions or > private section to hide a value is not the only way. "Information Hiding" is not about hiding information from programmers. It's about removing details that are irrelevant to clients of an interface to services, in order to give more flexibility to the implementation of a service and to make the client code's view of the service as essential as possible. This reduces the need to rewrite client code when the implementation of a service is modified. Tucker Taft had a way of characterizing the difference between the public and private parts of package specs that I still find appealing: the public part presents the logical interface to client code; the private part presents the physical part of the interface that is needed by the compiler for it to be efficient (or to deal with extra-language representation issues). This can be contrasted with more extreme approaches to "information hiding" that use opaque types in the overall spec, deferring all detail to the package body (and so invoking extra indirections). - Ed