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-05-01 01:58:42 PST Date: Thu, 01 May 2003 10:58:35 +0200 From: =?ISO-8859-1?Q?Rodrigo_Garc=EDa?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020513 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Generic formal access types References: <3eb01630@epflnews.epfl.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Host: lglpc31.epfl.ch Message-ID: <3eb0e1be$1@epflnews.epfl.ch> X-Trace: epflnews.epfl.ch 1051779518 128.178.76.8 (1 May 2003 10:58:38 +0200) Organization: EPFL Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!news.imp.ch!news.imp.ch!news-zh.switch.ch!epflnews.epfl.ch!not-for-mail Xref: archiver1.google.com comp.lang.ada:36795 Date: 2003-05-01T10:58:35+02:00 List-Id: Simon Wright wrote: > 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). Sorry, I meant: generic type Elment (<>) is private; -- Yes, (<>) allows Element to be unconstrained. type Access_Type is access Element; But the "problem" is still there. I have to pass an actual "Element" as well as an actual "Access_Type" when I instantiate the generic package. I would like to only pass the "Access_Type". > 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 .. You are probably right, but I am not dealing with tagged types here. My problem is much simpler. > 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! Hmmm... I was not thinking of that either. Just access to objects by now. :^) Rodrigo