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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2e66fe8b30e3ee2c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-10-02 22:23:42 PST Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!209.249.123.233.MISMATCH!xfer10.netnews.com!netnews.com!europa.netcrusader.net!63.211.125.72!cyclone2.usenetserver.com!news-out.usenetserver.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!news.mindspring.net!firehose.mindspring.com!not-for-mail From: Marin David Condic Newsgroups: comp.lang.ada Subject: Re: S'Write and How To Count Bytes Date: Tue, 03 Oct 2000 01:21:52 -0400 Organization: Quadrus Corporation Message-ID: <39D96CF0.6DF67DA0@acm.org> References: <878C5.275815$i5.3825407@news1.frmt1.sfba.home.com> NNTP-Posting-Host: d1.56.bd.07 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 3 Oct 2000 05:22:07 GMT X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:951 Date: 2000-10-03T05:22:07+00:00 List-Id: tmoran@bix.com wrote: > >... I will get out what I expect. > type Temperature is new Integer range 60 .. 80; > for Temperature'size use 8; -- or 7 > Is a Temperature'Write going to produce one byte, because that's how > big Temperature is, or 4 bytes, because that's how big Integer is? > type R is record > Speed : Long_Integer; > end record; > for R use record > S at 0 range 0 .. 7; > end record; > Will an R'Write produce one byte for S, or 8 or what? > Didn't say you couldn't create cases that would be tough to make work consistently. Said that if I used my head and declared my own primitive types that I would likely get what I wanted. It isn't that often that someone can't manage to live with "for X'Size use 8" > > >A perfect solution would be controlled representation of the (tagged) > >record types and a fast overlay of a Stream_Element_Array. > I remember this discussion, but not the bottom line. What's wrong > with > TAG_SIZE : constant := 4; > ... > type This_Buffer is new Buffer with record > Speed : Integer; > T : Temperature; > end record; > for This_Buffer use record > Speed at TAG_SIZE range 0 .. 7; > T at Tag_Size+1 range 0 .. 7; > end record; > and then overlay a Stream_Element_Array? (Or a > System.Storage_Elements.Storage_Array?) > I'd rather trust to TAG_SIZE being 4, or at least a single thing to > change, as I move between compilers, rather than trusting Stream stuff. Oh, you get part way there with that. There's a slew of other problems that come up and I'd just as soon not start that whole mess again. A lot of it involves being able to get a representation clause on the record elements and have the compiler give you what you want instead of what it wants. Problems with freezing rules. Problems with alignments when you extend the type, and so on. It really would be the elegant solution, but there doesn't seem to be a good way to make it happen in such a way that Ada will guarantee a compiler must do what you want it to do. I got tired of fighting the compiler, so I put it on the shelf until a later language revision. :-) If you're really curious, we could discuss it off-line. 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 ======================================================================