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: a07f3367d7,dbbbb21ed7f581b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Operation can be dispatching in only one type Date: Thu, 10 Dec 2009 19:10:08 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <025105f2-5571-400e-a66f-ef1c3dc9ef32@g27g2000yqn.googlegroups.com> <4b150869$0$6732$9b4e6d93@newsspool2.arcor-online.net> <18vlg095bomhd.8bp1o9yysctg$.dlg@40tude.net> <4b152ffe$0$7615$9b4e6d93@newsspool1.arcor-online.net> <19nhib6rmun1x$.13vgcbhlh0og9$.dlg@40tude.net> <4b1557d0$0$7623$9b4e6d93@newsspool1.arcor-online.net> <4b15bf2b$0$7623$9b4e6d93@newsspool1.arcor-online.net> <1jcbtmi5rztyp$.norvlhez9i9$.dlg@40tude.net> <4b179ffb$0$6591$9b4e6d93@newsspool3.arcor-online.net> <1gcigitaii0u0.1psu2vj52e66g$.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1260490199 977 192.74.137.71 (11 Dec 2009 00:09:59 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 11 Dec 2009 00:09:59 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:YPFs8NRm8AEoPK52FuvopiveKHU= Xref: g2news1.google.com comp.lang.ada:8365 Date: 2009-12-10T19:10:08-05:00 List-Id: stefan-lucks@see-the.signature writes: > On Mon, 7 Dec 2009, Randy Brukardt wrote: > >> "Dmitry A. Kazakov" wrote in message > >> > Why not to allow such constraints for subtypes? E.g. >> > >> > subtype Valid_Window_Type is Window_Type when Is_Valid; >> > >> > then simply: >> > >> > procedure Do_Something (Window : Valid_Window_Type; ...) >> >> That's also under consideration, > > Great! Yes, it is great. I am a strong advocate of this feature. But there are a lot of details to work out, and the feature might not make it into the language by 2012. We'll see. > Isn't that essentially the same as the invariants in Eiffel? Yes, it's quite similar. But there are some important differences, such as the fact that in Eiffel, a class is both a type and a module, whereas in Ada, we have types, subtypes, and packages as separate concepts. >> but there are some problems with it. One >> problem is that such types are very confusing in array indexes/slices (do >> the values all participate or just the ones that pass the predicate?) I consider such problems to be side issues. They are solvable, I think. > One way to solve^H^H^H^H^H^H circumvent this problem would be to prohibit > that kind of subtyping for discrete types. In Dmity's example above, > Window_Type is likely to be a record (probably a tagged one). If it is not > a discrete type, you can't use it as an array index. :-) I don't like that "solution" (or "circumvention", if you prefer). ;-) I think one important goal is to be able to have arbitrary subtypes of an enumeration type, in addition to just subranges. I don't much care about arrays indexed by such subtypes. subtype Vowel is Character with Predicate => To_Lower(Vowel) in ('a', 'e', 'i', 'o', 'u'); or something like that. Here, Vowel refers to the current instance of subtype Vowel. I don't particularly want an array indexed by Vowel, but I might want to say: case C is when Vowel => ...; when Consonant => ...; when Punctuation => ...; ... or: procedure P(X : Vowel); or: if X in Vowel ... - Bob