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: Tue, 03 Oct 2000 01:21:52 -0400
Date: 2000-10-03T05:22:07+00:00	[thread overview]
Message-ID: <39D96CF0.6DF67DA0@acm.org> (raw)
In-Reply-To: 878C5.275815$i5.3825407@news1.frmt1.sfba.home.com

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
======================================================================





  reply	other threads:[~2000-10-03  5:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-02  0:00 S'Write and How To Count Bytes tmoran
2000-10-03  5:21 ` Marin David Condic [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-10-03  0:00 Mario Amado Alves
2000-10-03  0:00 ` Marin David Condic
2000-09-30  0:00 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         ` Marin David Condic
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-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
replies disabled

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