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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ad06d2d7cb045687 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Received: by 10.68.222.71 with SMTP id qk7mr11518541pbc.1.1328544737914; Mon, 06 Feb 2012 08:12:17 -0800 (PST) Path: lh20ni267331pbb.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Silly and stupid post-condition or not ? Date: Mon, 06 Feb 2012 17:12:16 +0100 Organization: Ada @ Home Message-ID: References: <82wr86fzos.fsf@stephe-leake.org> <5af407fc-2868-44ca-84d2-c51a2a64104d@o4g2000pbc.googlegroups.com> <82k445fu9n.fsf@stephe-leake.org> <82ty36urik.fsf@stephe-leake.org> NNTP-Posting-Host: 97Fu/4vrcCucDaaFukdoug.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/11.61 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2012-02-06T17:12:16+01:00 List-Id: Le Mon, 06 Feb 2012 15:39:14 +0100, Robert A Duff = a =C3=A9crit: > "Yannick Duch=C3=AAne (Hibou57)" writes: > >> Seems nice, but given this=E2=80=A6 >> >> subtype Image_Type is String >> with Static_Predicate =3D> Image_Type'Length in Length_Type; >> >> function Image (Instance : Instance_Type) return Image_Type >> with Post =3D> >> (Parsed (Image'Result).Status =3D Parsed) and >> (Parsed (Image'Result).Instance =3D Instance); >> -- Result can always be successfully parsed and the resulting >> -- instance is always equal to the one whose image is returned.= >> >> =E2=80=A6how do I move Image's Post predicate to an Image_Type's dyna= mic >> predicate ? I could not figure the syntax nor if it's at least = >> possible. > > Not possible. Predicates can only express a property of a single > thing, but here you're trying to express a relationship > between two things (parameter and result). > > - Bob Sorry, my wording was unclear. Here is what I wanted, and it works: subtype Image_Type is String with Dynamic_Predicate =3D> (Image_Type'Length in Length_Type) and (Parsed (Image_Type).Status =3D Parsed); (don't know why it first failed, may be a syntax error) The predicate =E2=80=9CParsed (Image_Type).Status =3D Parsed=E2=80=9D is= better on = Image_Type than on Image. So thanks for your prior message which gave me this idea. Since now, wil= l = better think about moving predicates on types as much as possible. Indee= d = better. -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity