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,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Received: by 10.68.199.73 with SMTP id ji9mr12298804pbc.5.1327965104906; Mon, 30 Jan 2012 15:11:44 -0800 (PST) Path: lh20ni242705pbb.0!nntp.google.com!news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: =?utf-8?B?U2lsbHkgYW5kIHN0dXBpZCBwb3N04oCRY29uZGl0aW9uIG9yIG5vdMKgPw==?= Date: Tue, 31 Jan 2012 00:11:43 +0100 Organization: Ada @ Home Message-ID: NNTP-Posting-Host: hOhxFjD5Ra6sRCDG7KFvdw.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-01-31T00:11:43+01:00 List-Id: Hi people out there, A matter of style or more than style. I wanted to add a post=E2=80=91condition to a function to make its speci= fication = more predictive. The function returns a type =C3=A0 la SML, i.e. instead= of a = boolean status on failure along with an undefined value, it returns a = record containing nothing. There is an obvious case where it is sure to = = fail, so I wanted to express this obvious behavior in a post=E2=80=91con= dition. = But I can't make up my mind, can't clearly feel if that's simply silly a= nd = useless wast of source or else. May I request for your opinion on the simple sample please ? The main = point is on the function post=E2=80=91condition at the end. type Parsed_Type (Status : Parsed_Status_Type) is record case Status is when Parsed =3D> Instance : Instance_Type; when Format_Error =3D> null; end case; end record; -- Parsed_Type function Parsed (S : String) return Parsed_Type with Post =3D> (if S'Length not in Image_Length_Type then Parsed'Result.Status =3D Format_Error); -- There may be other failure conditions. Is such a post=E2=80=91condition a good or bad practice in your humble o= r = authoritative opinion ? Keep in mind there may be many other cases where =E2=80=9CParsed'Result.= Status =3D = Format_Error=E2=80=9D could be True; the one in the Post is not the only= possible = one. -- = =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