comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: Storage space question
Date: 1998/12/10
Date: 1998-12-10T00:00:00+00:00	[thread overview]
Message-ID: <74pkq0$8m9$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 74pfg4$3s6$1@nnrp1.dejanews.com

In article <74pfg4$3s6$1@nnrp1.dejanews.com>,
  callen@space.honeywell.com wrote:

> accomplish.  I have a hardware device that has registers I will access.  Lets
> say one register looks like this (identifiers have been changed to protect the
> innocent):
>
>    type REGISTER_1_Type is
>    record
>       field_1_Ctrl:             t_3bit;
>       field_2_Ctrl:             t_3bit;

> in the program). The reason is that I would like to make *many* of these.
> For the sake of argument, say there's 100 registers each with 8 bits worth of
> possibilities.	I don't want tables with all that info in there, just
the 100
> values that I'm using to initialize the thing to be put in the right place in

If its the value of the bits themseves that are important rather that the
value of the whole word (iaw: each bit has its own meaning independent of any
other bits), then I'd prefer to use arrays of boolean, indexed by an
enumeration. Note that the boolean operations "and", "or", and "not" will
automaticly work on any array of boolean you create. Yes you still have that
enumeration overhead, but now its just one string per bit, instead of 2^X
strings for X bits.

> Again, I'm using Ada83, and don't see a pragma that will help me.  I
> understand and agree with the dislike of preprocessors, but is what I'm
> trying to do (which textual subst would work for...) such a bad thing to ask
> for?

What you can do to get a similar effect (no runtime storage) in Ada is to use
named-numbers. eg:

Begin_Twadling : constant := 2#10010011#;

Unfortunately, this only works for Integeral types in Ada 83, and Ada 83
Integers are not really suited for this kind of use.

Fortunately, most Ada 83 compilers will treat many normal constants the same
as named numbers (iaw: no runtime storage) when they see that they can. This
sounds like what you are asking for.

Several people have pointed out that all this is easier in Ada 95. Yes there
are the pragmas. Also there's a modular Integer type that you can use your
named numbers with. Its a shame you can't upgrade.

--
T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  reply	other threads:[~1998-12-10  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-10  0:00 Storage space question Craig Allen
1998-12-10  0:00 ` dennison
1998-12-10  0:00 ` Marin David Condic
1998-12-10  0:00   ` Matthew Heaney
1998-12-10  0:00     ` dennison
1998-12-10  0:00   ` Pat Rogers
1998-12-10  0:00     ` dennison
1998-12-10  0:00       ` Pat Rogers
1998-12-10  0:00   ` Tucker Taft
1998-12-10  0:00     ` callen
1998-12-10  0:00       ` dennison [this message]
1998-12-10  0:00       ` Marin David Condic
1998-12-10  0:00         ` Tucker Taft
1998-12-11  0:00           ` dennison
1998-12-11  0:00         ` Matthew Heaney
1998-12-11  0:00           ` Marin David Condic
1998-12-12  0:00             ` Matthew Heaney
1998-12-12  0:00               ` David C. Hoos, Sr.
1998-12-12  0:00                 ` Matthew Heaney
1998-12-14  0:00                 ` dennison
1998-12-11  0:00       ` Matthew Heaney
replies disabled

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