* Direct_IO and files of tagged types
@ 2005-05-26 17:20 John McCormick
2005-05-26 18:22 ` Dmitry A. Kazakov
0 siblings, 1 reply; 4+ messages in thread
From: John McCormick @ 2005-05-26 17:20 UTC (permalink / raw)
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?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Direct_IO and files of tagged types
2005-05-26 17:20 Direct_IO and files of tagged types John McCormick
@ 2005-05-26 18:22 ` Dmitry A. Kazakov
2005-05-26 23:51 ` Randy Brukardt
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry A. Kazakov @ 2005-05-26 18:22 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Direct_IO and files of tagged types
2005-05-26 18:22 ` Dmitry A. Kazakov
@ 2005-05-26 23:51 ` Randy Brukardt
2005-05-27 8:38 ` Dmitry A. Kazakov
0 siblings, 1 reply; 4+ messages in thread
From: Randy Brukardt @ 2005-05-26 23:51 UTC (permalink / raw)
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:86bcmsy3e49m.yjhfcxtf7osr.dlg@40tude.net...
> 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!
If the object is derived from Controlled, it will be tagged even if no
(explicit) dispatching is used. And I think that virtually all ADT types
should be controlled and extensible -- so virtually all types will have
tags. At worst the overhead is "useless" now; but that probably will change
in the future.
My suggestion to John would be to abandon Direct_IO and use Streams instead;
'Write doesn't write the tag, and Stream_IO allows positioning. Once a type
is tagged, you usually want a hetrogeneous file anyway (that is, the type
probably ought to be T'Class, which isn't going to work with Direct_IO, and
is dubious with Sequential_IO).
Randy.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Direct_IO and files of tagged types
2005-05-26 23:51 ` Randy Brukardt
@ 2005-05-27 8:38 ` Dmitry A. Kazakov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry A. Kazakov @ 2005-05-27 8:38 UTC (permalink / raw)
On Thu, 26 May 2005 18:51:47 -0500, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:86bcmsy3e49m.yjhfcxtf7osr.dlg@40tude.net...
>> 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!
>
> If the object is derived from Controlled, it will be tagged even if no
> (explicit) dispatching is used. And I think that virtually all ADT types
> should be controlled and extensible
Right.
> -- so virtually all types will have
> tags. At worst the overhead is "useless" now; but that probably will change
> in the future.
What for? T'Class should have a tag. T should not.
Provided that T is not a by-reference, limited type then there is no any
good reason to put its tag into. I would really like to have *non-tagged*
controlled and extensible types for which I could have T'Class. Such types
could then be safely used in Direct_IO.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-05-27 8:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-26 17:20 Direct_IO and files of tagged types John McCormick
2005-05-26 18:22 ` Dmitry A. Kazakov
2005-05-26 23:51 ` Randy Brukardt
2005-05-27 8:38 ` Dmitry A. Kazakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox