From: "Alex Angas" <wgd@adelaide.on.net>
Subject: Instantiating a generic ADT from another ADT
Date: Mon, 23 Apr 2001 09:44:34 +0930
Date: 2001-04-23T09:44:34+09:30 [thread overview]
Message-ID: <3ae388e0@duster.adelaide.on.net> (raw)
Hey all, I'm having a great deal of trouble trying to instantiate a generic
list package ADT (with generic functions) from another ADT (a hash table
ADT). Can this even be done? I'm trying to create a linked list of hash
tables.
The problem is that I am declaring functions that use the as-yet undeclared
type of hash_table_list. The compiler isn't happy about just saying that
it's private so I tried to declare it at the end of the private section.
Didn't work! Compiler also isn't very happy about declaring that function to
be used by generic_list_package in the private section of hash_table.ads. I
really don't know how to do this. Here's the code:
*** hash_table.ads:
with generic_list_package;
package hash_table is
type hash_table_list is private;
function lookup(i : integer) return hash_table_list;
...
private
...
function get_key(i: in hash_table_entry) return integer;
-- this is a generic function in generic_list_package
package hash_table_list_package is new generic_list_package(
item_type => hash_table_entry,
key_type => integer);
type hash_table_list is new hash_table_list_package.item_list;
end hash_table;
*** generic_list_package.ads:
generic
type item_type is private; -- type stored in list
type key_type is private; -- type for comparing items in list
with function get_key(item: in item_type) return key_type is <>;
-- used for comparing keys
package generic_list_package is
type item_ptr is private;
type item_list is limited private;
.,.
end generic_list_package;
***
Any ideas??
Cheers, Alex.
next reply other threads:[~2001-04-23 0:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-23 0:14 Alex Angas [this message]
2001-04-23 2:46 ` Instantiating a generic ADT from another ADT Jeffrey Carter
2001-04-23 3:03 ` Alex Angas
2001-04-23 22:29 ` Des Walker
2001-04-23 23:48 ` Marc A. Criley
2001-04-24 5:26 ` Alex Angas
2001-04-24 6:31 ` Des Walker
2001-04-27 19:22 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox