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=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Style Question: normal record vs discriminated null-record. Date: Tue, 03 Jun 2014 06:38:37 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 3 Jun 2014 04:38:38 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="2b3884a634d8f846e0712b4e3a92507a"; logging-data="1711"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZM783AzuyP4KhP0GPVs0K" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: Cancel-Lock: sha1:782v3TDWf/HfDRGxQD0jEFnqUq8= X-Enigmail-Version: 1.6 Xref: number.nntp.dca.giganews.com comp.lang.ada:186710 Date: 2014-06-03T06:38:37+02:00 List-Id: Le 03/06/2014 04:44, Shark8 a écrit : > Ok, given some sort of alert-system (meaning there shouldn't be any/much > in the way of value manipulation of those objects) is it preferable to > use a discriminated null-record or a record with normal components? > > > Type Grievousness is (Warning, Error); > Type Circumstance is (Expired_Data, Bad_Request, Malformed_Data); > > Type Alert_1(Severity : Grievousness; Condition : Circumstance) is > null record; > > Type Alert_2 is record > Severity : Grievousness; > Condition : Circumstance; > end record; Depends how you perceive your data. Discriminants are intended to define some kind of subclasses of your type, and can be used to parameterized inner components. Some criteria for you to chose: - You can define subtypes according to certain values of discriminants. - Discriminants are always initialized. - Discriminants cannot be changed after the declaration. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr