comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: types in procedure arguments
Date: 1996/10/01
Date: 1996-10-01T00:00:00+00:00	[thread overview]
Message-ID: <32512127.6550@gsfc.nasa.gov> (raw)
In-Reply-To: 52piii$8n7@noc2.drexel.edu


At last! some real code.

Chris Papademetrious wrote:
> [snip]
>  Thank you for your time and energy, folks.  Several people have
> expressed interest in the outcome of this, and I thank you for your
> help in resolving it.
> 
>  - Chris
> with Tst_Double_List; -- double linked-list package
> with Tst_Vectors;
> 
> package Tst_Best_Congruence is
> 
>    package Vec_List is new Tst_Double_List(ELEMENT_OBJECT =>
> Tst_Vectors.Vector);
> 
>    procedure Best_Congruence
>    (
>       List: in out Vec_List.LIST_ID
>    );
> 
> end Tst_Best_Congruence;
> generic
>    type ELEMENT_OBJECT is private;
> package Tst_Double_List is
>    type LIST_ID is limited private;
> private
>    type LIST_ID is
>       record
>          Item1, Item2, Item3: ELEMENT_OBJECT;
>       end record;
> end Tst_Double_List;
> package Tst_Vectors is
>   type Vector is array (0..9) of Float;
> end Tst_Vectors;
> with Tst_Double_List; -- double linked-list package
> with Tst_Best_Congruence;
> with Tst_Vectors;
> 
> procedure Tst is
> 
>   package Vec_List is new Tst_Double_List(ELEMENT_OBJECT =>
> Tst_Vectors.Vector);

You don't want to do this second instantiation here.

>   L: Vec_List.LIST_ID;

This should be:

L :  Tst_Best_Congruence.Vec_List.LIST_ID;

> 
> begin
> 
>   Tst_Best_Congruence.Best_Congruence(L);

Using full names for clarity, the "LIST_ID" type this call wants to see
is Tst_Best_Congruence.Vec_List.LIST_ID (the one declared in
Tst_Best_Congruence), not Test.Vec_List.LIST_ID (the one declared in
Tst). In cases like this, you can always write down the full names of
things to see what's going on. Instantiating a package a second time
produces a distinct type, and Ada gives it a distinct name.

> 
> end Tst;

> -=-=-=-=-=-=-=-=-=-=-=-=-
>  Chris Papademetrious
>  Data Fusion Laboratory
>  Drexel University
>  Philadelphia, PA
> -=-=-=-=-=-=-=-=-=-=-=-=-

-- 
- Stephe




  parent reply	other threads:[~1996-10-01  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-23  0:00 types in procedure arguments Chris Papademetrious
1996-09-25  0:00 ` Stephen Leake
1996-09-28  0:00 ` Chris Papademetrious
1996-09-28  0:00 ` Chris Papademetrious
1996-09-30  0:00 ` Chris Papademetrious
1996-10-01  0:00   ` Norman H. Cohen
1996-10-01  0:00   ` Robert A Duff
1996-10-01  0:00   ` Stephen Leake [this message]
1996-10-01  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-09-28  0:00 Robert Dewar
1996-09-30  0:00 ` Chris Papademetrious
1996-09-30  0:00   ` Norman H. Cohen
1996-09-30  0:00   ` Stephen Leake
replies disabled

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