comp.lang.ada
 help / color / mirror / Atom feed
* Instantiating a generic ADT from another ADT
@ 2001-04-23  0:14 Alex Angas
  2001-04-23  2:46 ` Jeffrey Carter
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Angas @ 2001-04-23  0:14 UTC (permalink / 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.






^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-04-27 19:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-23  0:14 Instantiating a generic ADT from another ADT Alex Angas
2001-04-23  2:46 ` 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

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