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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ca15935e4fb21334 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Storage space question Date: 1998/12/12 Message-ID: <74tr9g$ei4$1@tsunami.traveller.com>#1/1 X-Deja-AN: 421509540 References: <366FE278.FAF73497@pwfl.com> <74pfg4$3s6$1@nnrp1.dejanews.com> <36704ADB.73FA308D@pwfl.com> <3671463B.33E291@pwfl.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: Traveller Information Services Newsgroups: comp.lang.ada Date: 1998-12-12T00:00:00+00:00 List-Id: Matthew Heaney wrote in message ... >Marin David Condic 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.