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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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.204.154.76 with SMTP id n12mr452444bkw.1.1341004202117; Fri, 29 Jun 2012 14:10:02 -0700 (PDT) Path: y28ni56bky.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: about the new Ada 2012 pre/post conditions Date: Fri, 29 Jun 2012 14:03:27 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1jvy3elqtnd1j.1sjbk32evhp1f$.dlg@40tude.net> <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> NNTP-Posting-Host: 96.2.54.122 Mime-Version: 1.0 X-Trace: posting.google.com 1341004201 3544 127.0.0.1 (29 Jun 2012 21:10:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 29 Jun 2012 21:10:01 +0000 (UTC) Cc: mailbox@dmitry-kazakov.de In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=96.2.54.122; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-06-29T14:03:27-07:00 List-Id: > > What do pre/post implement, if so, in your view? >=20 > 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. 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; Procedure Default_Handler( Object : NN_Access_Some ); defines a a function [spec] in which the body may assume that Object is not= null, as if it is it will raise Constraint_Error, thereby allowing us to g= et rid of the checking logic within the function. How does pulling that out into the Pre clause in Ada 2012 change things? Al= so, is not the general concept now generalizable? (IE so that these assumpt= ions may be safely made.) I'm really confused on why you seem to think the Pre- and Post-conditions a= re bad things. That you can compile something that *could* violate them is = irrelevant, you could do the same with the given default_handler procedure,= especially if you were pulling it from user-input. It has a well defined b= ehavior for the error of trying to pass null in, and moreover you can catch= -and-correct it if it is correctable. Post seems a bit less useful than Pre, but maybe that's because I'm being u= nimaginative today.