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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news4.google.com!feeder.news-service.com!xlned.com!feeder3.xlned.com!feeder.erje.net!news-2.dfn.de!news.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: Operation can be dispatching in only one type Date: Tue, 8 Dec 2009 05:30:30 +0100 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <025105f2-5571-400e-a66f-ef1c3dc9ef32@g27g2000yqn.googlegroups.com> <59acf311-3a4a-4eda-95a3-22272842305e@m16g2000yqc.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> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: tigger.scc.uni-weimar.de 1260261268 28816 141.54.178.228 (8 Dec 2009 08:34:28 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Tue, 8 Dec 2009 08:34:28 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: Xref: g2news1.google.com comp.lang.ada:8343 Date: 2009-12-08T05:30:30+01:00 List-Id: 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! Isn't that essentially the same as the invariants in Eiffel? > 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?) 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. :-) In any case, you definitively would not want to allow that kind of type for array indexes, if only the values which the predicate being true is allowed. How would you efficiently implement something like subtype Primes is Positive when Is_Prime; A: array (Primes (10_000 .. 20_000)) of T; -- 10_001 primality tests B: array (Primes (Start .. Stop)) of T; -- Start-Stop+1 such tests -- possibly at runtime > Another issue is that not all preconditions/postconditions can be written > this way. For one thing, a precondition can depend on multiple parameters at > once. Another issues is that the entry condition and exit conditions may be > different for a parameter. Right. That is precisely why Eiffel distinguishes preconditions, postconditions and invariants -- and supports all the three. -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------