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 X-Google-Thread: 103376,b1ebfe7f8f5e385d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-30 12:27:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Generic formal access types Date: 30 Apr 2003 20:27:32 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <3eb01630@epflnews.epfl.ch> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.demon.co.uk 1051730874 27691 62.49.19.209 (30 Apr 2003 19:27:54 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Wed, 30 Apr 2003 19:27:54 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: archiver1.google.com comp.lang.ada:36777 Date: 2003-04-30T20:27:32+01:00 List-Id: Rodrigo Garc�a writes: > Does anybody know why Ada does not have something like: > > generic > type Access_Type is access (<>); -- ? > > I would like to specify in a generic package that it should be > instantiated by an access type, no matter what type it is pointing > to. > > Ok, it is not very useful to have an access type if you do not know > its content, but the package implements a list and I am just storing > them. I "need" that because I want to return the value "null" from a > function in the generic package that returns "Access_Type". > > There is a possible workaround: > > generic > type Element is (<>); > type Access_Type is access Element; > > But I do not like it because it forces me to pass also the "Element" > in the instantiation. I think 'type Element is limited private' would be better (I can't rememer if you can allow it to be unconstrained as well, 'type Element (<>) is limited private' ... GNAT is happy). I can understand why a formal type has to be tagged for you to declare it abstract, you would have thought a private constraint { (<>) } would have been a possibility here .. There's no way I can see that you can instantiate a generic with an access-to-subprogram, but I'm not sure that the uses would be worth the trouble!