comp.lang.ada
 help / color / mirror / Atom feed
Subject: Re: Generic formal access types
Date: Fri, 02 May 2003 11:52:05 +0200
Date: 2003-05-02T11:52:05+02:00	[thread overview]
Message-ID: <3eb23fca$1@epflnews.epfl.ch> (raw)
In-Reply-To: 5Ejsa.170717$gK.261651@rwcrnsc52.ops.asp.att.net

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




  reply	other threads:[~2003-05-02  9:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-30 18:30 Generic formal access types 
2003-04-30 19:27 ` Simon Wright
2003-05-01  8:58   ` 
2003-04-30 21:42 ` Chad R. Meiners
2003-05-01  9:06   ` 
2003-05-01  9:58     ` Martin Krischik
2003-05-01 13:00       ` 
2003-05-02  9:14         ` Ludovic Brenta
2003-05-02 10:43           ` 
2003-05-02 10:50             ` 
2003-05-01 10:09     ` 
2003-05-02  1:14 ` tmoran
2003-05-02  9:52   `  [this message]
2003-05-02 16:18     ` tmoran
2003-05-02 16:57       ` Robert A Duff
2003-05-02 19:39         ` Randy Brukardt
2003-05-05  8:14         ` 
2003-05-05 16:40         ` Matthew Heaney
2003-05-05 17:34           ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox