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,cd45439466e86f24 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: enumeration type Date: Mon, 27 Sep 2004 16:48:07 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de xKpGzAXI4CeSPIsfzYfHFwVBKR4L2OhNFRKJRC+lo0siCZq38= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:4273 Date: 2004-09-27T16:48:07+02:00 List-Id: On Mon, 27 Sep 2004 14:19:03 +0000 (UTC), Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: >:> If you don't dislike writing down what you want to say, >:> you can use qualified notation: > >:> if b = Boolean'(True) and v = Ternary_Logical'(True) then > >: What for? > > Rick asked, > "How can I now access the True-element from the original Standard.Boolean > type?" > > Then, sometimes it is not necessary to stress that v is of type > Ternary_Logical or b of type Boolean, or to mention True at all > as in Peter Hermann's example. Sometimes added qualification > helps (me) understanding the software if there is some redundant > type information, because it reduces the need to look at context. Yes, but fundamental literals like numbers, strings, and logical values too, tend to overload each other. In case of logical literals it is because True is same in both(all) logics. Three-state logic is a continuation of Boolean logic. It is very rare when somebody would really need to fully qualify literals. Like in: function "and" (Left, Right : Ternary_Logical) return Ternary_Logical; function "and" (Left : Boolean, Right : Ternary_Logical) return Ternary_Logical; function "and" (Left : Ternary_Logical, Right : Boolean) return Ternary_Logical; function Read (File : File_Type) return Boolean; function Read (File : File_Type) return Ternary_Logical; X : Ternary_Logical := Read (File) and Read (File); -- Ambiguous Which is a bad style anyway. > For example, if your function returns a value of record type Foo, > you could write > > return (bar => 7, baz => comp_result); > > or > return Foo'(bar => 7, > baz => comp_result); (*) > > or > return (7, comp_result); (**) > > or > return Foo'(7, comp_result); > > In cases ** is just fine for me, in other cases I like * because > it unambiguously tells me, the reader, what is returned. > > Aggregates must be qualified in SPARK, iirc. It is a valid point, but is not applicable for non-composite types. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de