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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.112.42.236 with SMTP id r12mr33458954lbl.2.1435093398700; Tue, 23 Jun 2015 14:03:18 -0700 (PDT) X-Received: by 10.140.37.129 with SMTP id r1mr572135qgr.18.1435093398079; Tue, 23 Jun 2015 14:03:18 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!feed118.news.tele.dk!u14no11866862lbd.1!news-out.google.com!4ni2562qgh.1!nntp.google.com!q107no2935610qgd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 23 Jun 2015 14:03:17 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=83.99.95.58; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 83.99.95.58 References: <9894cde7-2cf8-4060-be65-857812ad7b09@googlegroups.com> <17436268-aceb-461f-bdcf-eee8436cd0e6@googlegroups.com> <86y4jaqzdx.fsf@stephe-leake.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: What do you think about this? From: Laurent Injection-Date: Tue, 23 Jun 2015 21:03:18 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:26446 Date: 2015-06-23T14:03:17-07:00 List-Id: On Tuesday, 23 June 2015 22:20:37 UTC+2, Anh Vo wrote: > I would suggest to improve the last two functions with the following prec= onditions. That means any attempt to pass an String whose length is longer = than 40 characters will be slapped by the run time. >=20 > --... > with pre =3D> Right <=3D V_String_Length; >=20 > Anh Vo You mean like this? Sry no idea on how to use pre/post conditions. function "+" (Right : String) return V_String.Bounded_String is (V_String.To_Bounded_String (Right)) with pre =3D> Right <=3D V_String_Length; This doesn't compile.=20 Builder results /Volumes/Kingston/GPS/Generateur_Trame_Vitek/common_defs_bci.ads 16:16 expected type universal integer 16:16 found type "Standard.String" Either it is normal or I put the with... at the wrong place. If I change to with pre =3D> V_String.Length(V_String.To_Bounded_String(Rig= ht)) <=3DV_String_Length; than it compiles but I don't see a difference in behavior. If I try to conv= ert a string longer than max_lenght of V_String then my program dies with r= aised ADA.STRINGS.LENGTH_ERROR : a-strsup.adb:1926. That happens without th= e precondition but also with it? The switch -gnata is enabled (found in the ada gems? that is required for t= he evaluation of the Pre/post conditions). Thanks Laurent