comp.lang.ada
 help / color / mirror / Atom feed
* Conceptual Ada Problems
@ 1996-09-29  0:00 Vasilios Tourloupis
  1996-09-29  0:00 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vasilios Tourloupis @ 1996-09-29  0:00 UTC (permalink / raw)



Dear Ada users,

I have a few questions regarding Ada, which hopefully someone
will be able to answer:

* Is there some way I would be able to access key fields
  of generic data types (records)?

* 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?

* I am not quite sure how to declare functions/procedures as formal
  parameters to a function/procedure.

* 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!

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.

Thanx in advance,

Bill Tourloupis
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Vasilios E. Tourloupis             | vasilios@insect.sd.monash.edu.au |
| Dept. of Software Development      | vasilios@hestia.sd.monash.edu.au |
| Monash University,                 |                /\                |
| Caulfield East, Vic., 3145         |___________/\  /  \_______________|
| Australia                          |             \/                   | 
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Disclaimer: There are some that call me Bill!  But I don't know why?  |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+





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

* Re: Conceptual Ada Problems
  1996-09-29  0:00 Conceptual Ada Problems Vasilios Tourloupis
  1996-09-29  0:00 ` Matthew Heaney
@ 1996-09-29  0:00 ` Larry Kilgallen
  1996-09-29  0:00   ` Robert Dewar
  1996-10-01  0:00 ` Dale Stanbrough
  2 siblings, 1 reply; 5+ messages in thread
From: Larry Kilgallen @ 1996-09-29  0:00 UTC (permalink / raw)



In article <Pine.GSO.3.93.960929230049.29986A-100000@firefly.sd.monash.edu.au>, Vasilios Tourloupis <vasilios@insect.sd.monash.edu.au> writes:

> * 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?

That sounds like an indexed file system, and Ada standards have not
included the specification of such.  DEC Ada for VMS includes packages
to access the RMS indexed file system which is already present on that
operating system.  I would presume that in other environments which
have an indexed file system Ada vendors likewise supply such packages
so all customers do not have to reinvent the wheel.

One could of course write a portable indexed file system in Ada,
but considering the degree of system-specific optimization generally
provided for indexed file systems, the performance of a portable
system would likely be unsatisfactory.

Larry Kilgallen




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

* Re: Conceptual Ada Problems
  1996-09-29  0:00 Conceptual Ada Problems Vasilios Tourloupis
@ 1996-09-29  0:00 ` Matthew Heaney
  1996-09-29  0:00 ` Larry Kilgallen
  1996-10-01  0:00 ` Dale Stanbrough
  2 siblings, 0 replies; 5+ messages in thread
From: Matthew Heaney @ 1996-09-29  0:00 UTC (permalink / raw)



In article
<Pine.GSO.3.93.960929230049.29986A-100000@firefly.sd.monash.edu.au>,
Vasilios Tourloupis <vasilios@insect.sd.monash.edu.au> 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 (<args here>);
   procedure Generic_Op (<its args here>);

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




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

* Re: Conceptual Ada Problems
  1996-09-29  0:00 ` Larry Kilgallen
@ 1996-09-29  0:00   ` Robert Dewar
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1996-09-29  0:00 UTC (permalink / raw)



Larry said

"That sounds like an indexed file system, and Ada standards have not
included the specification of such.  DEC Ada for VMS includes packages
to access the RMS indexed file system which is already present on that
operating system.  I would presume that in other environments which
have an indexed file system Ada vendors likewise supply such packages
so all customers do not have to reinvent the wheel.

One could of course write a portable indexed file system in Ada,
but considering the degree of system-specific optimization generally
provided for indexed file systems, the performance of a portable
system would likely be unsatisfactory."


Actually indexed file systems like this are largely obsolete. Even in
COBOL programs, people do not use indexed file IO often any more. Instead
they interface to an appropriate data base manager (of course that DB
manager uses some kind of indexed IO, but the extra level of abstraction
is highly valuable).





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

* Re: Conceptual Ada Problems
  1996-09-29  0:00 Conceptual Ada Problems Vasilios Tourloupis
  1996-09-29  0:00 ` Matthew Heaney
  1996-09-29  0:00 ` Larry Kilgallen
@ 1996-10-01  0:00 ` Dale Stanbrough
  2 siblings, 0 replies; 5+ messages in thread
From: Dale Stanbrough @ 1996-10-01  0:00 UTC (permalink / raw)




>I have a few questions regarding Ada, which hopefully someone
>will be able to answer:
>
>* Is there some way I would be able to access key fields
>  of generic data types (records)?

I presume you mean accessing the fields of a record inside a generic.
Not directly (after all the generic may be instantiated with type
integer, which has no fields!). You can supply a function to access
components of a record for your.


>* 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?

No, you have to build up an index yourself. you could save it to disc of
course, rather than building it up each time the program runs.


>* I am not quite sure how to declare functions/procedures as formal
>  parameters to a function/procedure.

Declare the subprograms at the library level, and then do...

	type func_ptr is access function (required profile) required return type


you can then take the 'access of a subprogram.

	
>* 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!


you can't have generic linked lists, only generic packages & subprograms.
you may have a diff. problem to this, but this is all i can make out
of your description.

Dale




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

end of thread, other threads:[~1996-10-01  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-29  0:00 Conceptual Ada Problems Vasilios Tourloupis
1996-09-29  0:00 ` Matthew Heaney
1996-09-29  0:00 ` Larry Kilgallen
1996-09-29  0:00   ` Robert Dewar
1996-10-01  0:00 ` Dale Stanbrough

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