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,901038687c38f61c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: Idiom for a class and an object in Ada References: <417683de$0$91007$39cecf19@news.twtelecom.net> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 21 Oct 2004 01:36:47 GMT NNTP-Posting-Host: 64.185.133.124 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1098322607 64.185.133.124 (Wed, 20 Oct 2004 18:36:47 PDT) NNTP-Posting-Date: Wed, 20 Oct 2004 18:36:47 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:5555 Date: 2004-10-21T01:36:47+00:00 List-Id: "Matthew Heaney" writes: > I showed in an earlier post how to use access types, but hide the fact > that access types are used: > > package P is > type T (<>) is limited private; > procedure Op (O : in T); > function O1 return T; > function O2 return T; > private > type Rep_Type is limited ... end record; > > type T is access all Rep_Type; > for T'Storage_Size use 0; > end P; Actually, I forgot to mention that you don't need an access type if you use an array to hold the objects: package P is type T (<>) is limited private; procedure Op (O : in T); function O1 return T; function O2 return T; private type T is range 1 .. 2; end P; package body P is type Rep_Type is limited record ... end record; Objects : Rep_Type (T); procedure Op (O : in T) is OO : Rep_Type renames Objects (O); begin ... end; function O1 return T is begin return 1; end; function O2 return T is begin return 2; end; end P; In fact, you don't need the private type at all: package P is type T is (O1, O2); procedure Op (O : in T); end P; package body P is type Rep_Type is limited record ... end record; Objects : Rep_Type (T); procedure Op (O : in T) is OO : Rep_Type renames Objects (O); begin ... end; end P;