comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Storage space question
Date: 1998/12/12
Date: 1998-12-12T00:00:00+00:00	[thread overview]
Message-ID: <m3pv9pnc5m.fsf@mheaney.ni.net> (raw)
In-Reply-To: 3671463B.33E291@pwfl.com

Marin David Condic <condicma@bogon.pwfl.com> writes:

> > As long as you only use the constants (not the literals), you get all
> > the type safety that an enumeration type buys you.
> > 
> > Which is why rep clauses for enumeration types is overkill, that adds
> > unnecessary complexity to the language.
> 
> Well, not quite all the type safety. Suppose that the field occupies 3
> bits but only the values 0, 1 and 2 are currently valid. Or worse, only
> the values 2#001#, 2#010# and 2#100# are valid. With an integer type,
> there is no way of eliminating the invalid values. With enumerations,
> you can't accidentally get an invalid bit pattern assigned to the
> register field.

"As long as you only use the constants (not the literals), you get all
the type safety that an enumeration type buys you."

The object will never get assigned the values 3 .. 7, because those
values aren't named by constants.

If you stick to the constants, then there is no loss of type safety.











  reply	other threads:[~1998-12-12  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 ` Marin David Condic
1998-12-10  0:00   ` Tucker Taft
1998-12-10  0:00     ` callen
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 [this message]
1998-12-12  0:00               ` David C. Hoos, Sr.
1998-12-12  0:00                 ` Matthew Heaney
1998-12-14  0:00                 ` dennison
1998-12-10  0:00       ` dennison
1998-12-11  0:00       ` Matthew Heaney
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   ` Matthew Heaney
1998-12-10  0:00     ` dennison
1998-12-10  0:00 ` dennison
replies disabled

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