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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1f8689f27f0e2d9a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Correct use of variants References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Mon, 07 Nov 2005 19:46:26 GMT NNTP-Posting-Host: 67.3.209.122 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1131392786 67.3.209.122 (Mon, 07 Nov 2005 11:46:26 PST) NNTP-Posting-Date: Mon, 07 Nov 2005 11:46:26 PST Xref: g2news1.google.com comp.lang.ada:6272 Date: 2005-11-07T19:46:26+00:00 List-Id: Maciej Sobczak wrote: > > What is the correct way to achieve the declaration of A with the > possibility of changing the discriminant later? One of the ways is to > use *some* default value for the discriminant, but I might have > difficulty deciding which value is better than the others for this role. > An arbitrary choice would create a misleading message to the reader that > the particular value is considered to be "best" or "idle" or "starting" > or whatever. In addition, having a default value for the discriminant > means that it's not obligatory to initialize the variable A while it's > declared and I would like to keep this enforced. Note that having a non-defaulted discriminant does not require initialization: A : Discriminated (Which => First); There was a thread on here a while ago about requiring and enforcing initialization; you might want to search for it. The options included using unknown discriminants with an initializing function; using a controlled type; and using a private type with a default initialized field that indicates that the object has not been initialized, an operation that initializes objects of the type and indicates that they have been initialized, and all other operations raising an exception if the value indicates a lack of initialization. -- Jeff Carter "Sir Lancelot saves Sir Gallahad from almost certain temptation." Monty Python & the Holy Grail 69