comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent <lutgenl@icloud.com>
Subject: Re: What do you think about this?
Date: Tue, 23 Jun 2015 14:03:17 -0700 (PDT)
Date: 2015-06-23T14:03:17-07:00	[thread overview]
Message-ID: <edda2110-5468-4c8a-8679-4f1edf96b01e@googlegroups.com> (raw)
In-Reply-To: <b6dfc2ca-979c-4f16-8eca-8d4439c84db8@googlegroups.com>

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 preconditions. That means any attempt to pass an String whose length is longer than 40 characters will be slapped by the run time.
> 
>    --...
>    with pre => Right <= V_String_Length;
> 
> 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 => Right <= V_String_Length;

This doesn't compile. 

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 => V_String.Length(V_String.To_Bounded_String(Right)) <=V_String_Length;
than it compiles but I don't see a difference in behavior. If I try to convert a string longer than max_lenght of V_String then my program dies with raised ADA.STRINGS.LENGTH_ERROR : a-strsup.adb:1926. That happens without the precondition but also with it?

The switch -gnata is enabled (found in the ada gems? that is required for the evaluation of the Pre/post conditions).

Thanks

Laurent

  reply	other threads:[~2015-06-23 21:03 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-21 18:38 Is there an easier way for this? Laurent
2015-06-21 19:15 ` Niklas Holsti
2015-06-21 19:41   ` Laurent
2015-06-21 19:25 ` Jeffrey R. Carter
2015-06-21 19:42   ` Laurent
2015-06-22 12:23   ` Laurent
2015-06-22 15:01     ` G.B.
2015-06-22 15:40       ` Laurent
2015-06-22 16:47     ` Jeffrey R. Carter
2015-06-22 16:41   ` Laurent
2015-06-22 16:47     ` Jeffrey R. Carter
2015-06-22 17:18       ` Laurent
2015-06-22 18:04         ` What do you think about this? Laurent
2015-06-23 14:21           ` Stephen Leake
2015-06-23 19:51             ` Laurent
2015-06-23 20:20               ` Anh Vo
2015-06-23 21:03                 ` Laurent [this message]
2015-06-23 22:17                   ` Shark8
2015-06-24  5:57                     ` Anh Vo
2015-06-24  7:58                       ` Laurent
2015-06-24 21:06                       ` Laurent
2015-06-24 21:45                         ` Anh Vo
2015-06-24 21:59                           ` Laurent
2015-06-24 22:35                           ` Simon Wright
2015-06-24 22:59                             ` Laurent
2015-06-25  2:56                               ` Anh Vo
2015-06-25  7:29                               ` Simon Wright
2015-06-25 16:55                                 ` Anh Vo
2015-06-25 17:27                                   ` Simon Wright
2015-06-25 18:13                                 ` Laurent
2015-06-25 18:36                                   ` Simon Wright
2015-06-24 23:10                             ` Anh Vo
2015-06-24 10:17               ` Stephen Leake
2015-06-24 17:20                 ` Jeffrey R. Carter
2015-06-24 20:50                   ` Laurent
2015-06-24 22:30                     ` Jeffrey R. Carter
2015-06-24 22:52                       ` Laurent
2015-06-27 17:12                       ` Laurent
2015-06-27 17:43                         ` Jeffrey R. Carter
2015-06-27 17:47                         ` J-P. Rosen
2015-06-27 18:54                         ` Simon Wright
2015-06-27 19:37                           ` Laurent
2015-06-27 19:47                             ` Jeffrey R. Carter
2015-06-27 20:39                             ` Simon Wright
2015-06-28  4:45                             ` J-P. Rosen
2015-06-28 14:08                         ` Stephen Leake
2015-06-28 16:10                           ` Laurent
2015-06-25 13:16                   ` Stephen Leake
2015-06-25 17:20                     ` Jeffrey R. Carter
2015-07-02 21:51                       ` Randy Brukardt
2015-07-03 12:31                         ` Stephen Leake
2015-07-03 17:11                           ` Laurent
2015-07-03 17:46                             ` Jeffrey R. Carter
2015-07-03 18:49                               ` Laurent
2015-07-04  3:26                                 ` Randy Brukardt
2015-07-03 19:17                             ` Simon Wright
2015-07-04  3:30                               ` Randy Brukardt
2015-07-04  4:19                                 ` Laurent
2015-07-04  7:43                                   ` Simon Wright
2015-07-04  9:07                                     ` Laurent
2015-07-04  7:42                                 ` Simon Wright
2015-07-05  0:56                                   ` Randy Brukardt
2015-07-03 17:35                           ` Randy Brukardt
2015-07-05 13:55                             ` Stephen Leake
2015-07-06 20:07                               ` Randy Brukardt
2015-06-24 20:21                 ` Laurent
2015-06-21 19:38 ` Is there an easier way for this? Pascal Obry
2015-06-21 19:54   ` Laurent
2015-06-21 20:39     ` Pascal Obry
2015-06-24  7:14 ` gautier_niouzes
2015-06-24 21:08   ` Laurent
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox