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,e61c8636ef35379d X-Google-Attributes: gid103376,public From: Marin David Condic Subject: Re: Ada Streams usage (was Escape Sequences in Strings) Date: 2000/11/19 Message-ID: <3A182633.BDE82EA9@acm.org>#1/1 X-Deja-AN: 695488123 Content-Transfer-Encoding: 7bit References: <3A17B0E2@MailAndNews.com> <3A129A89.1B69E2FE@acm.org> <3A13D59E.63A6F92@earthlink.net> <3A168546.89CA38F7@acm.org> <3A177878.AD747325@telepath.com> To: Ted Dennison X-Accept-Language: en X-Server-Date: 19 Nov 2000 19:13:23 GMT Content-Type: text/plain; charset=us-ascii Organization: Quadrus Corporation Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-11-19T19:13:23+00:00 List-Id: Ted Dennison wrote: > ...unless you have overridden the 'Read and 'Write attributes. In that case *you* > decide how to break the object into stream elements (not *precisely* bytes, but > probably the same in practice). > Berzactly!!! And *then* you start getting into the Deviled-Details. For most of your primitive and compound types, you may be all right to accept whatever the compiler does for 'Read and 'Write - except that you get no guarantees of representation - which can be a *real bitch!* if you have to pass stuff down a wire to some unknown listener who is expecting things to occupy precise positions within the stream. It works O.K. if you're going to create a stream file and read it back in later with the same program - then you don't really care - maybe. (Useful for building something like the "Serialize" functions in MFC/C++) Or you can take your compound types and do some intensive representation control and through some reliable mechanism (overlays, for example) convert them to a Stream_Element_Array and now they go down the hose the way you want them to. Unless, of course, it is a tagged record type and then you open up all sorts of cans of worms concerning representation. To get around that, there are techniques, but you then have to *continually* write your own overrides for every child type instead of having a single class-wide operation: Some_Type'Class'Write - which would be really cool to have if you could make it work. For some things, just accepting what the compiler gives you is a pretty good choice. If your working only internal to a single program, or the communications are between two programs compiled by the same compiler for the same OS and same machine, then whatever the compiler generates is probably going to work OK - for a while - until someone makes a mess of it by changing compiler versions or using your data for some third system, etc. In my experience, the minute you start broadcasting data to another system, you had better get good control of the representation or you'll really hate yourself later. And the instant you have to write code that deals with someone else's defined flow of data, you can just bag the whole thing if you don't want to get outside the default 'Read. It is *almost* a really wonderful thing to have Streams. :-) 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 ======================================================================