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-02 09:57:46 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!panix!newsfeed!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Generic formal access types Date: 02 May 2003 12:57:46 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <3eb23fca$1@epflnews.epfl.ch> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1051894666 32680 199.172.62.241 (2 May 2003 16:57:46 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 2 May 2003 16:57:46 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:36870 Date: 2003-05-02T12:57:46-04:00 List-Id: tmoran@acm.org writes: > Why not > declare > package Instance is new Generic_Package (Integer); > subtype Ptr is Instance.Node_Content_Ptr; > P : Ptr; 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. 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. 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. - Bob