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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ca85d557480cf473 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-06 18:58:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3D27A023.C483C92F@computer.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Hiding a type References: <3D27263F.7070101@hotmail.com> <7kJV8.2438$gy3.1099236449@newssvr12.news.prodigy.com> <3D2733F4.8010304@hotmail.com> <3D275160.40907@hotmail.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sun, 07 Jul 2002 01:58:10 GMT NNTP-Posting-Host: 63.184.17.202 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1026007090 63.184.17.202 (Sat, 06 Jul 2002 18:58:10 PDT) NNTP-Posting-Date: Sat, 06 Jul 2002 18:58:10 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:26918 Date: 2002-07-07T01:58:10+00:00 List-Id: Ryan Tarpine wrote: > > It looked correct when I wrote it, but that's not saying much since I > only have a week of study under my belt :) GNAT tells me > > test.ads:2:10: missing full declaration for private type "Public_Name" > test.ads:8:13: "Public_Name" conflicts with declaration at line 2 You should pay attention to compiler messages. These are telling you 2 important things 1. There is no completion for the private type Public_Name 2. You cannot have a subtype with the same name as a type in the same declarative region. What you still seem to be missing, although you've been presented with several examples doing it correctly, is that the completion ("full declaration" in ARM-speak) of a private type is itself a type declaration, not a subtype declaration: package P is type T is limited private; private -- P type T is new Integer; end P; There is no way in Ada to declare a type for which you cannot declare an object. Limited private is good, since assignment is not defined for limited types, and you might also want to add unknown discriminants to the public view of the type: type T (<>) is limited private; Now the client cannot create a variable of the type, but can create a constant by renaming a function call: function F return T; ... V : T renames F; Another approach may be to use the package-as-object technique. In this way of doing things, you would declare a generic package with only subprograms exported. The data is declared in the body of the package. Each instance of the package becomes an object with the subprograms acting as the operations on that object. -- Jeff Carter "You cheesy lot of second-hand electric donkey-bottom biters." Monty Python & the Holy Grail