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 02:52:14 PST Date: Fri, 02 May 2003 11:52:05 +0200 From: =?UTF-8?B?Um9kcmlnbyBHYXJjw61h?= 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> <5Ejsa.170717$gK.261651@rwcrnsc52.ops.asp.att.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: lglpc31.epfl.ch Message-ID: <3eb23fca$1@epflnews.epfl.ch> X-Trace: epflnews.epfl.ch 1051869130 128.178.76.8 (2 May 2003 11:52:10 +0200) Organization: EPFL 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!colt.net!peernews3.colt.net!newsfeed.stueberl.de!solnet.ch!solnet.ch!news.imp.ch!news.imp.ch!news-zh.switch.ch!epflnews.epfl.ch!not-for-mail Xref: archiver1.google.com comp.lang.ada:36842 Date: 2003-05-02T11:52:05+02:00 List-Id: tmoran@acm.org wrote: >>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". > > What's wrong with > generic > type Element is (<>); First of all, I wrote this too fast and it is erroneous. It should read: generic type Element (<>) is private; > package Lists is > type Node_Content_Ptr is access Element; If I declare the access type in the package, I will have a problem with the return type of the function: function Whatever return Node_Content_Ptr; Because I already have access types defined where I do the instantiation. declare type Ptr is access Integer; package Instance is new Generic_Package (Integer); P : Ptr; begin P := Instance.Whatever; end; Here, P is of type "Ptr" and the function returns "Node_Content_Ptr". For the compiler to accept this, I will have to declare Ptr as "access all Integer" and do an explicit conversion: P := Ptr (Instance.Whatever); Since I cannot change the definition of Ptr, this solution is not valid for me... Nice try, though! :^) Rodrigo