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,5add429c86f59001 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.velia.net!noris.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 10 Jun 2009 13:10:37 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada vs Eiffel - Ada programmer approach References: <405b5054-4c8f-4e16-9ea8-503a9b9f976e@t21g2000yqi.googlegroups.com> <4A19765C.608@obry.net> <8105b65f-4de9-4653-b43a-d55ee33f072d@k2g2000yql.googlegroups.com> <88f38fe3-01ec-407f-b7b6-84a1d10de7f1@h11g2000yqb.googlegroups.com> <878wk299uj.fsf@willow.rfc1149.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <4a2f94ad$0$31872$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 10 Jun 2009 13:10:37 CEST NNTP-Posting-Host: 842a82b3.newsspool3.arcor-online.net X-Trace: DXC=9^5WE6X:QEOlU`@c^jLCbJMcF=Q^Z^V3H4Fo<]lROoRA^YC2XCjHcbIVFX03I1?Jb@;9OJDO8_SKFNSZ1n^B98iJ[6o5HY0n=6E X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6414 Date: 2009-06-10T13:10:37+02:00 List-Id: Hibou57 (Yannick Duch�ne) schrieb: > On 8 juin, 21:37, Robert A Duff wrote: >> I have expressed the opinion that invariants and/or user-defined >> constraints should apply to subtypes, not just types. Not everyone >> agrees. > I agree too > As subtypes have specific properties on value (it it is a subset), > specific constraints may come with it. I wonder if to have invariants with subtypes is the more practical alternative? Also, what about overlapping subtypes? What if invariants of two subtypes are contradictory? Consider subtypes of the same type ... range 1 .. 10; ... range 0 .. 10; Should it be possible for these two subtypes to have further invariants/constraints that could possibly contradict each other? (An object from the first range can now be used where an object of the second is expected.) I'm considering a programming use case, such as this: procedure Op(X: Whole_Number_Subtype; Result: T); pragma Precondition(X rem 2 = 1); This lets me think that *not* having a constraint with the subtype Whole_Number_Subtype is more flexible, at least if I'd be tempted to define another subtype for imposing the set predicate X rem 2 = 1. (As long as we don't have a type system for type constraints like Dmitry Kazakov has suggested some time ago IIUC...)