comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <mcondic.nospam@acm.org>
Subject: Re: S'Write and How To Count Bytes
Date: 2000/10/02
Date: 2000-10-02T20:20:28+00:00	[thread overview]
Message-ID: <39D8EDFF.CCDEFD7F@acm.org> (raw)
In-Reply-To: Sv4C5.275540$i5.3820691@news1.frmt1.sfba.home.com

tmoran@bix.com wrote:

>   I still don't understand.  Is each Integer'Write generating a call to
> the IO routine, or is it writing into a buffer, which will be passed
> to the IO routine when it contains the entire composite record?  In
>

Having tested this in the past by putting Text_IO calls into the stream code, you
appear to get a call for each elementary data object. This will be, of course,
compiler dependent. Granted, its just a memory-to-menory operation rather than an
actual I/O (up to you to do the I/O and you can wait for the buffer to fill.) so the
cost is not extraordinary. But still, all those subprogram calls and memory moves
add up if the structure gets big or you simply do a lot of them. I'd consider it
ill-advised on a hard-realtime project with limited CPU.

>    It seems to me this indicates that Stream_IO may simply be
> inappropriate for such an application.  The only way you can really know
> where the bytes are is via record rep clauses, or by writing your own
> 'Writes to handle everything in your records.  If you depend on the
> compiler, even for Integer'Write, some compiler might some day decide to
> write integers in Roman numeral form, or in some error-correcting code
> expanded form, or whatever, and there goes your app.  My understanding
> is that the only thing you can depend on from the compiler is the
> *sequence* of 'Write calls.

Well, you don't get any absolute guarantees. Look at ARM 13.13.2 {17} and the
surrounding stuff. It seems to imply that if I don't put anything wierd into the
record that I will get out what I expect. In other words, make the record elements
out of things you've defined and controlled representation on such as your own
integers, etc., of known sizes. If I had something like:

type X is record
    Int1   : SInt_32 ;
    Int2  : SInt_16 ;
    Flt1  : Float_96 ;
end record ;

Even if the compiler puts in padding to longword align everything, when I do the
'Write, I should get back what I expect - barring perverse implementations. As you
note, I could create my own 'Write for everything and be certain of what I get.

A perfect solution would be controlled representation of the (tagged) record types
and a fast overlay of a Stream_Element_Array. If you had all the attributes you
needed and could get the representation you wanted, you could very rapidly shove the
bytes down the hose, complete with checksums and byte counts and all the stuff you
want. You'd preserve dispatching and all the high level stuff that made extending
the messages painless, preserved information hiding, let you have all the type
abstractions you wanted and kept the callers from doing any sort of bit-twiddling.
Only problem is, I've tried very hard to make that work and can't get there without
ugly compromises.

MDC
--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

    "Giving money and power to Government is like giving whiskey
    and car keys to teenage boys."

        --   P. J. O'Rourke
======================================================================






  parent reply	other threads:[~2000-10-02  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-30  0:00 S'Write and How To Count Bytes Marin David Condic
2000-10-01  0:00 ` David C. Hoos, Sr.
2000-10-02  0:00   ` Marin David Condic
2000-10-02  0:00     ` Ted Dennison
2000-10-02  0:00       ` tmoran
2000-10-02  0:00         ` tmoran
2000-10-02  0:00           ` Marin David Condic
2000-10-11  0:00             ` Nick Roberts
2000-10-11  0:00               ` Marin David Condic
2000-10-02  0:00           ` Ted Dennison
2000-10-02  0:00         ` Marin David Condic [this message]
2000-10-03  0:00       ` Robert A Duff
2000-10-06  0:00         ` Randy Brukardt
2000-10-07  0:11           ` Ted Dennison
2000-10-06  0:00             ` Randy Brukardt
2000-10-07  0:00             ` Marin David Condic
2000-10-08  0:00               ` Jean-Pierre Rosen
2000-10-09  0:00                 ` Randy Brukardt
2000-10-11  0:00                 ` Marin David Condic
2000-10-02  0:00   ` Dr. Joachim Schr�er
2000-10-02  0:00     ` Marin David Condic
2000-10-06  0:00       ` Charles Hixson
2000-10-02  0:00 ` David C. Hoos, Sr.
2000-10-02  6:58 ` tmoran
2000-10-02  0:00   ` Marin David Condic
  -- strict thread matches above, loose matches on Subject: below --
2000-10-02  0:00 tmoran
2000-10-03  5:21 ` Marin David Condic
2000-10-03  0:00 Mario Amado Alves
2000-10-03  0:00 ` Marin David Condic
replies disabled

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