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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7137ee7358078d09 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Basic Explaination of OO in Ada Date: Tue, 19 Sep 2006 18:14:00 +0200 Message-ID: <4naja2F9iufgU1@individual.net> References: <1158593087.194781.250030@e3g2000cwe.googlegroups.com> <1158636734.971377.112550@d34g2000cwd.googlegroups.com> <1158674185.887102.205150@m73g2000cwd.googlegroups.com> <1158679879.965952.156540@m73g2000cwd.googlegroups.com> <4nai8dF97euuU1@individual.net> <1158681993.370326.304680@k70g2000cwa.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net my1it/dXpY70RJjiGGZtswUdZ2pcrKQ5w7t8lrrtFeqfzVf9A= User-Agent: KNode/0.10.4 Xref: g2news2.google.com comp.lang.ada:6672 Date: 2006-09-19T18:14:00+02:00 List-Id: Ludovic Brenta wrote: > Alex R. Mosteo wrote: >> Just a note: although what Ludovic writes is right, and you can only have >> vanilla arrays of definite types, you can have more sophisticated >> containers (for example Ada.Containers.Indefinite_Vectors) that store >> class-wide types in Ada 2005: >> >> package Pak_Vectors is >> new Ada.Containers.Indefinite_Vectors (Positive, Pak.T'Class); >> >> In this case, however, you store copies so some overhead can occur, but >> in many cases it can be more convenient than starting to play with >> pointers. > > Doesn't Ada.Containers.Indefinite_Vectors have to declare a class-wide > access type for its internal use? I'd guess so. But, it hides the > access type from the user, and that's encapsulation at its best. Yep, I suppose so (but I didn't looked for it). > In Ada, one rarely needs access types at all. The only justification > for declaring one is because you're doing some kind of dynamic data > structure and allocating dynamically on the heap. With the standard > Ada.Containers, you'd need access types even less often. Agreed. > That's why in my examples I did not declare an access type along with > the tagged type (in package P); instead, I declared an access type in > another package (package Collection) because that package absolutely > needed one. Ok, I missed your intention with the example here, so I was trying to make clear that one shouldn't be too keen on jumping to access types :)