From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cafbdf9d858c8e74 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Conceptual Ada Problems Date: 1996/09/29 Message-ID: #1/1 X-Deja-AN: 186107070 references: content-type: text/plain; charset=ISO-8859-1 organization: Estormza Software mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-09-29T00:00:00+00:00 List-Id: In article , Vasilios Tourloupis wrote: >* Is there some way I would be able to access key fields > of generic data types (records)? I'm not sure what you mean: Can you be more specific? >* Is there some way of storing/retrieving records in an Ada.Direct_IO > file using key fields of records rather than their location in the file? As far as I know, the only way to retrieve records using Direct_IO all by itself is via the Index. Of course, you could create another abstraction the does allow you to retrieve records via a key field, that is implemented using Direct_IO. You could keep the key-to-index map in a (smaller) seperate file, so that your abstraction actually comprises 2 files. When you initialize the abstraction, it could read into memory the key-to-index file, and during lookups, use that info to determine the index position of the record in the direct file. >* I am not quite sure how to declare functions/procedures as formal > parameters to a function/procedure. If you're using Ada 83, then make the package or the subprogram generic: generic with procedure P (); procedure Generic_Op (); or generic with procedure P (...); package Generic_Ops is To use it, you instantiate it: procedure P (...) is ... procedure Op is new Generic_Op (P); If you're using Ada 95, then you can still do that, and in addition declare subprogram pointers: type P_Access is access procedure (...); procedure Op (..., P : P_Access); Then no instantiation is required: procedure P (...) is ... Op (... P'Access); Give me an example of what you want to do. >* Also, the Ada compiler complains about some subtype mark being > required, in declaring an array comprising of generic linked lists. > Any suggestions on how to overcome this are more than welcome, as > I have been trying all day, to no avail! Show me the code that doesn't compile, and then I'll be able to tell you why. Make sure your array comprises an actual type: you don't get a type from a generic package directly, only from its instantiation: generic type T is private; package Lists is type List is private; ... type List_Array is (Positive range <>) of Lists.List; -- not legal Ada Instantiate first: package Integer_Lists is new Lists (Integer); type Integer_List_Array is (Positive range <>) of Integer_Lists.List; -- OK >Basically, what I am trying to implement is an hash table with the >ability to save and load records to and from a direct IO file, >respectively. Any other suggestions and/or pointers are more than >welcome. Again, maybe you want to store off the map (hash table) in another file. Of course, if you are using Ada 95, then you could play around with Streams_IO. It lets you do heterogeneous storage, so maybe you wouldn't need 2 separate (homogeneous) file. >Bill Tourloupis Matt -------------------------------------------------------------------- Matthew Heaney Software Development Consultant mheaney@ni.net (818) 985-1271