From: gilmour@banda.lv (gilmour)
Subject: Error message: expect valid subtype mark to instantiate ....
Date: 24 Dec 2003 05:13:13 -0800
Date: 2003-12-24T05:13:13-08:00 [thread overview]
Message-ID: <4138e9c3.0312240513.377090e8@posting.google.com> (raw)
Compiling 'Client_Account_List.ads' following message appears:
client_account_list.ads:4:47: expect valid subtype mark to instantiate "T"
Somebody please advise, what is wrong ???
These are the code samples:
-- Class_List.ads
with Ada.Finalization, Unchecked_Deallocation;
use Ada.Finalization;
generic
type T is private; --Any type
package Class_List is
type List is new Controlled with private;
procedure Initialize (
The : in out List );
procedure Initialize (
The : in out List;
Data : in T );
procedure Finalize (
The : in out List );
procedure Adjust (
The : in out List );
function "=" (
F : in List;
S : in List )
return Boolean;
private
type Node; --Tentative declaration
type P_Node is access all Node; --Pointer to Node
type Node is
record
Prev : P_Node; --Previous Node
Item : T; --The physical item
Next : P_Node; --Next Node
end record;
type List is new Controlled with
record
First_Node : aliased P_Node := null; --First item in list
Last_Node : aliased P_Node := null; --First item in list
end record;
end Class_List;
-- Class_List.adb
package body Class_List is
procedure Dispose_Node is
new Unchecked_Deallocation( Node, P_Node );
procedure Release_Storage (
The : in out List ) is
Cur : P_Node := The.First_Node; --Pointer to curr node
Tmp : P_Node; --Node to dispose
begin
while Cur /= null loop --For each item in list
Tmp := Cur; --Item to dispose
Cur := Cur.Next; --Next node
Dispose_Node( Tmp ); --Dispose of item
end loop;
end Release_Storage;
procedure Initialize (
The : in out List ) is
begin
The.First_Node := null; --Empty list
The.Last_Node := null; --Empty list
end Initialize;
procedure Initialize (
The : in out List;
Data : in T ) is
begin
The.First_Node := new Node'(null, Data, null);
The.Last_Node := The.First_Node;
end Initialize;
procedure Finalize (
The : in out List ) is
begin
if The.First_Node /= null then
Release_Storage( The );
The.First_Node := null;
end if;
end Finalize;
procedure Adjust (
The : in out List ) is
Cur : P_Node := The.First_Node; --Original list
Lst : P_Node := null; --Last created node
Prv : P_Node := null; --Previously created node
Fst : P_Node := null; --The first node
begin
while Cur /= null loop
Lst := new Node'( Prv, Cur.Item, null );
if Fst = null then
Fst := Lst;
end if;
if Prv /= null then
Prv.Next := Lst;
end if;
Prv := Lst;
Cur := Cur.Next; --Next node
end loop;
The.First_Node := Fst; --Update
The.Last_Node := Lst;
end Adjust;
function "=" (
F : in List;
S : in List )
return Boolean is
F_Node : P_Node := F.First_Node; --First list
S_Node : P_Node := S.First_Node; --Second list
begin
while F_Node /= null and S_Node /= null loop
if F_Node.Item /= S_Node.Item then
return False; --Different items
end if;
F_Node := F_Node.Next;
S_Node := S_Node.Next;
end loop;
return F_Node = S_Node; --Both NULL if equal
end "=";
end Class_List;
-- Class_Client_Acount.ads
with Gnat.Sockets; use Gnat.Sockets;
package Class_Client_Account is type Client_Account is tagged private;
procedure Set_Id(The : in out Client_Account; Id : String);
procedure Set_Channel(The : in out Client_Account; Channel : Stream_Access);
function Get_Id(The : in Client_Account) return String;
function Get_Channel(The : in Client_Account) return Stream_Access;
private
type Client_Account is tagged
record
Id : String(1 .. 8);
Channel : Stream_Access;
end record;
end Class_Client_Account;
-- Class_Client_Acount.adb
package body Class_Client_Account is
procedure Set_Id(The : in out Client_Account; Id : String) is
begin
The.Id:=Id;
end;
procedure Set_Channel(The : in out Client_Account; Channel : Stream_Access) is
begin
The.Channel:=Channel;
end;
function Get_Id(The : in Client_Account) return String is
begin
return The.Id;
end Get_Id;
function Get_Channel(The : in Client_Account) return Stream_Access is
begin
return The.Channel;
end Get_Channel;
end Class_Client_Account;
-- Client_Account_List.ads
with Class_List;
with Class_Client_Account;
pragma Elaborate_All(Class_List);
package Client_Account_List is new Class_List(Class_Client_Account);
next reply other threads:[~2003-12-24 13:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-24 13:13 gilmour [this message]
2003-12-24 17:04 ` Error message: expect valid subtype mark to instantiate 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