From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Storage space question
Date: 1998/12/12
Date: 1998-12-12T00:00:00+00:00 [thread overview]
Message-ID: <74tr9g$ei4$1@tsunami.traveller.com> (raw)
In-Reply-To: m3pv9pnc5m.fsf@mheaney.ni.net
Matthew Heaney wrote in message ...
>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.
>
Well, what if the data structure was filled by, say, a read from a network.
Use of the enumeration allows you to apply the 'valid test.
next prev parent 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 ` dennison
1998-12-10 0:00 ` Marin David Condic
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
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. [this message]
1998-12-12 0:00 ` Matthew Heaney
1998-12-14 0:00 ` dennison
1998-12-11 0:00 ` Matthew Heaney
1998-12-10 0:00 ` Matthew Heaney
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