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,146d9a693430fff2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada2012 Invariants and obaque types Date: Wed, 22 Jun 2011 10:00:47 +0200 Organization: cbb software GmbH Message-ID: <1il5w6m4gt3xd$.1s01y6lkslfjf.dlg@40tude.net> References: <239a78ad-0937-4a7a-8163-231430fd5ffe@k27g2000yqn.googlegroups.com> <17t4afbmsrbm4.7llaajq91zz3.dlg@40tude.net> <1rxmqjvvd0nk6.1pqiavml8xwzf.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news1.google.com comp.lang.ada:20001 Date: 2011-06-22T10:00:47+02:00 List-Id: On Tue, 21 Jun 2011 23:18:49 +0200, Manuel Collado wrote: > El 21/06/2011 20:53, Dmitry A. Kazakov escribi�: >> On Tue, 21 Jun 2011 20:37:44 +0200, Yannick Duch�ne (Hibou57) wrote: >> >>> Le Tue, 21 Jun 2011 14:08:15 +0200, Dmitry A. Kazakov >>> a �crit: >>> >>>> On Tue, 21 Jun 2011 01:53:31 -0700 (PDT), Martin wrote: >>>> >>>>> package P1 is >>>>> type T1 is tagged private >>>>> with Invariant => Is_Valid (T1); >>>> >>>> Unrelated to Ada, but in theory, an invariant is a private implementation >>>> dependent thing. An invariant is trivially true in all public views of >>>> the object, >>> I understand the point and had the same first feeling too. >> >> The first feeling is always the right one. (:-)) >> >>> While that's OK >>> in theory, in practice the user may wish methods to check for validity >>> rules defined for a type. >> >> Validity is a misconception. In a properly typed language any value is >> valid, that is the property of being typed. A value is invalid when the >> type system was circumvented, which should never happen publicly. > > Humm... What about an integral type whose set of valid values are the > prime numbers (upto some representation limit)? Prime numbers (as a set) are not numbers (e.g. do not form an additive group: if p1, p2 are primes, p1 + p2 is not necessarily prime.) > Common practice is to define such type as Integer, Natural or Positive, > and write some validation function to check values at runtime. To have a publicly integer type of only prime numbers would be a bad idea. > Or do you mean that Ada is not a properly typed language? Ada's typing is better than of any other language I know. Yes, it has issues, especially with construction-destruction of tagged types, nobody is perfect. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de