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: 103376,b78c363353551702 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.223.40 with SMTP id qr8mr4861318pbc.0.1341044785211; Sat, 30 Jun 2012 01:26:25 -0700 (PDT) X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.181.72 Path: l9ni1570pbj.0!nntp.google.com!news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!nntpfeed.proxad.net!78.192.181.72.MISMATCH!gegeweb.42!gegeweb.eu!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: about the new Ada 2012 pre/post conditions Date: Sat, 30 Jun 2012 10:26:12 +0200 Organization: cbb software GmbH Message-ID: <1otknesgpcisl$.112pd12on3vsb$.dlg@40tude.net> References: <1oih2rok18dmt.avbwrres5k12.dlg@40tude.net> <4fe59ea0$0$9502$9b4e6d93@newsspool1.arcor-online.net> <1mkp7fzlk1b0y.1ueinfjn48fcy$.dlg@40tude.net> <4fe72b6b$0$9504$9b4e6d93@newsspool1.arcor-online.net> <1bbvp3ghpjb5s.1go1s1qvcmagh$.dlg@40tude.net> <4fe76fad$0$9507$9b4e6d93@newsspool1.arcor-online.net> <1jt8vhzxfrv2i.eohce4d3rwx1$.dlg@40tude.net> <4fe83aaa$0$6624$9b4e6d93@newsspool2.arcor-online.net> <1pkfv0tiod3rn$.onx6dmaa3if9$.dlg@40tude.net> <1i1mp8xs3vtl2.1oc4m66qtfgzq.dlg@40tude.net> <4fe9bde5$0$6566$9b4e6d93@newsspool4.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 9A8bJrx4NhDLcSmbrb6AdA.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-06-30T10:26:12+02:00 List-Id: On Fri, 29 Jun 2012 14:03:27 -0700 (PDT), Shark8 wrote: >>> What do pre/post implement, if so, in your view? >> >> if Pre(...) then >> >> if Post(...) then >> null; >> else >> raise Constraint_Error; >> end if; >> else >> raise Constraint_Error; >> end if; > > Ok, but this is just what preconditions [and post] are supposed to do. [That is POV #1] No they are not. True pre-/post-conditions are not supposed to implement anything. Formally speaking, pre-/post-conditions are statements of another language L. The language Ada is what you use to program some P. P operates bits and bytes. The language L is used to operate P itself. In L you can say Correct (P) or Incorrect (P). > After all, we had a way to specify some preconditions before (in Ada 2005): > Type Some_Type is ...; > Type Access_Some is Access Some_Type; > Subtype NN_Access_Some is Not Null Access_Some; It is important to understand that constraint is not a precondition. > How does pulling that out into the Pre clause in Ada 2012 change things? Ignoring the fact that the name is misguiding, it is bad because ad-hoc. It hugely extends the number of places where anonymous subtypes may appear. Effectively a constraint on the argument defines a subtype for the purpose of this only subprogram and this only argument. I am not against extending algebra of subtypes, but it should be done with great care. > I'm really confused on why you seem to think the Pre- and Post-conditions > are bad things. That is because you didn't follow the discussion. Pre- and post-conditions are great things, but only when done correctly. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de