comp.lang.ada
 help / color / mirror / Atom feed
* why does this work?  private new types.
@ 2002-05-06 14:24 chris.danx
  2002-05-06 14:57 ` Jean-Pierre Rosen
  0 siblings, 1 reply; 7+ messages in thread
From: chris.danx @ 2002-05-06 14:24 UTC (permalink / raw)


Hi,

This example code will explain it better than I can.


with hash_tables;  -- generic
package blah is

   subtype word is string (some_range);

   type table is private;

   procedure add (a : in word;
                  t : in out table);

   ...

   private
      ... -- some functions in here

      package tables is new hash_tables
         (items => word,
          size => 100, -- for quickyness!
          hash_function => hash_function,
          equals => equals, to_string => to_string);

      type table is new tables.hash_table;

end blah;


package body blah is

   procedure add (a : in word;
                  t : in out table) is
   begin
      insert (a, t); -- *** here ***
   end add;

end blah;


insert is defined in hash_tables, so why can it be used in the body of blah
without "using" it?  Is it implicitly "used" when table is defined as a
'new' hash_table (i.e. it's allowed to be used .  That'd kindof make sense,
but is this the correct way to think of it, or is there a better way?

Seems like you learn new things about Ada every day!


Thanks,
Chris





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

end of thread, other threads:[~2002-05-10  2:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-06 14:24 why does this work? private new types chris.danx
2002-05-06 14:57 ` Jean-Pierre Rosen
2002-05-06 15:28   ` chris.danx
2002-05-09 17:05   ` Kai Schuelke
2002-05-09 17:17     ` David C. Hoos
2002-05-09 17:29     ` Stephen Leake
2002-05-10  2:14       ` Jeffrey Carter

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