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,6501d9f1c65bd0d1 X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: Ada 83: Type defaults Date: 1996/09/11 Message-ID: <3236F243.7FAA@syspac.com>#1/1 X-Deja-AN: 179966116 references: <516mkh$d3m@ryker.dma.gov> cc: John_Volan@syspac.com content-type: text/plain; charset=us-ascii organization: Science Applications International Corp. (SAIC) mime-version: 1.0 reply-to: John_Volan@syspac.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0Gold (Macintosh; I; PPC) Date: 1996-09-11T00:00:00+00:00 List-Id: hehmeyerj wrote: > > This may be a simple problem but... > > I have an enumeration type declaration. For example: > > type x is (A, B, C, D); > > And I have about three hundred variables of type x scattered throughout > 50 packages. How would you default the type to, say A, without going > to each individual variable declaration and explicitly defaulting them. > (ie y : x := A;) > > TIA You can't specify a default value for a scalar type (e.g. enumeration type) but you can for a record type (whether public or private): package P is -- whatever you originally had X in type X is private; function A return X; -- returns X'(Value => A_Value) function B return X; -- returns X'(Value => B_Value) function C return X; -- returns X'(Value => C_Value) function D return X; -- returns X'(Value => D_Value) -- Don't know how much enumeration semantics you need, but you may -- need to declare overloadings for "<", ">", "<=", ">=", and -- something that can take the place of 'Succ, 'Pred, etc. If you really -- need to be able to iterate over X in a for loop, you're out of -- luck, sorry private type X_Value is (A_Value, B_Value, C_Value, D_Value); type X is record Value : X_Value := A_Value; -- default end record; end P; -- package body left as an exercise for the reader :-) ... ------------------------------------------------------------------------ Internet.Usenet.Put_Signature (Name => "John G. Volan", Home_Email => "John_Volan@syspac.com", Employer => "S.A.I.C.", Work_Email => "John_Volan@dayton.saic.com", Slogan => "Ada95: The World's *FIRST* International-Standard OOPL", Disclaimer => "My employer never defined these opinions, so using " & "them is totally erroneous...or is that a bounded error now? :-)"); ------------------------------------------------------------------------