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,2e66fe8b30e3ee2c X-Google-Attributes: gid103376,public From: Marin David Condic Subject: Re: S'Write and How To Count Bytes Date: 2000/10/02 Message-ID: <39D8EDFF.CCDEFD7F@acm.org>#1/1 X-Deja-AN: 676766067 Content-Transfer-Encoding: 7bit References: <8raa11$nmg$1@nnrp1.deja.com> X-Accept-Language: en X-Server-Date: 2 Oct 2000 20:20:28 GMT Content-Type: text/plain; charset=us-ascii Organization: Quadrus Corporation Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-10-02T20:20:28+00:00 List-Id: 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 ======================================================================