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,b1ebfe7f8f5e385d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-05 09:40:31 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Generic formal access types Date: 5 May 2003 09:40:31 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0305050840.4a1ffd48@posting.google.com> References: <3eb23fca$1@epflnews.epfl.ch> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1052152831 11474 127.0.0.1 (5 May 2003 16:40:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 5 May 2003 16:40:31 GMT Xref: archiver1.google.com comp.lang.ada:36975 Date: 2003-05-05T16:40:31+00:00 List-Id: Robert A Duff wrote in message news:... > > That works only if you want to declare the pointer type at the same > place where the instantiation is. In many cases, you don't. For this > reason, it's almost always better to pass the pointer type into > generics. That is indeed how the Charles library works wrt the Generic_Element function: the client has to supply the access type. To ensure complete generality for a reuseable component, passing in the access type is the correct choice, since in many cases the client already has an access type that goes with the designated type. http://home.earthlink.net/~matthewjheaney/charles/ > When I invented the Address_To_Access_Conversions package (see chap 13), > I made the mistake of declaring the pointer type inside the generic, > because I thought the primary use would be peek/poke functionality, so > you would always say ".all" right away. And it makes the instantiation > simpler. But it turns out to be a pain. I think a bigger problem is that the declared pointer type doesn't turn off the storage pool. If the designated type is T'Class, doesn't this drag a lot of extra run-time baggage? If you're converting from Address to Object_Pointer, then there's no storage pool anyway, so it never made sense to me to give Object_Pointer a storage pool. > The "right" solution to the OP's problem is to pass in the designated > type and the pointer type. Yes, that requires an extra line of code at > the instantiation. But I don't think there's a better solution. Yes.