Re: Direct_IO and files of tagged types



On 26 May 2005 10:20:09 -0700, John McCormick wrote:

> When I instantiate a version of Ada.Direct_IO with an element type that
> is statically tagged (it is of a specific tagged type) GNAT gives me a
> warning that the element type contains an access value. My tagged type
> has three integer fields - no access types. I assume that the access
> type referenced in the warning is to the tag mechanism. Any suggestions
> for ways to create binary files of statically tagged objects?

It is not a good idea to write tags into a file even if they are statically
known, because that cannot be portable. Another general question is: if the
tag is always known what for to have it? Without dispatching tags are just
useless overhead!

Anyway what about:

1. Aggregation: you put a plain record into tagged type and do I/O with
that record.

2. A completely independent record type used for external representation of
tagged objects.

3. Handles/smart pointers: tagged objects refer to a plain record type via
an access discriminant or an access type.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.