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,7137ee7358078d09 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!postnews.google.com!k70g2000cwa.googlegroups.com!not-for-mail From: "Ludovic Brenta" Newsgroups: comp.lang.ada Subject: Re: Basic Explaination of OO in Ada Date: 19 Sep 2006 09:06:33 -0700 Organization: http://groups.google.com Message-ID: <1158681993.370326.304680@k70g2000cwa.googlegroups.com> 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> NNTP-Posting-Host: 212.190.145.10 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1158681999 27838 127.0.0.1 (19 Sep 2006 16:06:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 19 Sep 2006 16:06:39 +0000 (UTC) In-Reply-To: <4nai8dF97euuU1@individual.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 SEVPXS01 Complaints-To: groups-abuse@google.com Injection-Info: k70g2000cwa.googlegroups.com; posting-host=212.190.145.10; posting-account=ZjNXewwAAADyBPkwI57_UcX8yKfXWOss Xref: g2news2.google.com comp.lang.ada:6671 Date: 2006-09-19T09:06:33-07:00 List-Id: 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. 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. 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. -- Ludovic Brenta.