comp.lang.ada
 help / color / mirror / Atom feed
From: Serge Robyns <serge.robyns@gmail.com>
Subject: Re: Problems with SPARK 2015 and XMLAda
Date: Wed, 19 Aug 2015 14:22:42 -0700 (PDT)
Date: 2015-08-19T14:22:42-07:00	[thread overview]
Message-ID: <6952b70d-a9bc-4d0a-beb5-1cd38d6a3318@googlegroups.com> (raw)
In-Reply-To: <lymvxn112j.fsf@pushface.org>

Hi Simon,

Manually editing the grp file as suggested did the trick.

Sadly I quickly abandoned SPARK as it barked on me for using bounded strings.  I intend to use a DB with my application and bounded strings seems to be the way to go, even if I do find them a pain to use.  For every type of string I've to instantiate the generic package as I want to have strong typing on the usage of these strings throughout the program and this is one of my drivers to use Ada.

And I know many other things SPARK doesn't like, like exceptions (not used (yet)) or access types.  So I guess it must dislike the standard containers too.

I guess I'll uninstall SPARK, as so far it hasn't been so helpful for me.
For example in another small toy (a little game) I'm using the following construct.

      Count1      : Natural range 0 .. Number_Of_Columns;
      Count2      : Natural range 0 .. Number_Of_Columns;
      The_Score   : Integer := 0;
      J           : Columns;

      --  To speed up, the value is calculated as a delta
      --  from the previous value.
      --  This is the less good code of this game (I'm not proud).
   begin
      --
      --  Horizontal
      --
      Count1 := 0;
      if Column > Columns'First then
         for J in reverse Columns'First .. Columns'Pred (Column)
         loop
            exit when The_Board.Board (Row, J) /= Player;
            Count1 := Count1 + 1;
            pragma Loop_Invariant ( Count1 <= Number_Of_Columns - Integer (Columns'First - Columns'Pred (Column)));
            pragma Loop_Variant ( Increases => Count1 );
            pragma Loop_Variant ( Decreases => J );
         end loop;
      end if;
      Count2 := 0;
      if Column < Columns'Last then
      for J in Columns'Succ (Column) .. Columns'Last
      loop
         exit when The_Board.Board (Row, J) /= Player;
         Count2 := Count2 + 1;
         pragma Loop_Invariant ( Count2 < Number_Of_Columns );
         pragma Loop_Variant ( Increases => Count2 );
         pragma Loop_Variant ( Increases => J );
      end loop;
   end if;

SPARK warns about potential range errors on Count1 and Count2 while I've put a lot of safeguards and tried two different Loop_Invariant constructs to tell SPARK to be happy.  For every construct attempt I get a different error.

I'm not going to waste my time fighting SPARK and put my trust in the standard ADA features and testing.  To bad not being able to proof.

Serge

  reply	other threads:[~2015-08-19 21:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19 15:58 Problems with SPARK 2015 and XMLAda Serge Robyns
2015-08-19 20:21 ` Simon Wright
2015-08-19 21:22   ` Serge Robyns [this message]
2015-08-20  7:10     ` Jacob Sparre Andersen
2015-08-20 10:06       ` Mark Lorenzen
2015-08-20 16:38     ` Shark8
2015-08-20 18:42       ` Peter Chapin
2015-08-20 19:13         ` Jeffrey R. Carter
2015-08-20 20:00       ` Serge Robyns
2015-08-20 20:36       ` Randy Brukardt
2015-08-20 23:21         ` Shark8
2015-08-21  6:26         ` Stefan.Lucks
2015-08-21  7:30           ` Dmitry A. Kazakov
2015-08-21  8:19             ` Stefan.Lucks
2015-08-21  9:37               ` Dmitry A. Kazakov
2015-08-21 10:09                 ` G.B.
2015-08-21 11:56                   ` Dmitry A. Kazakov
2015-08-21 13:46                     ` G.B.
2015-08-21 14:45                       ` brbarkstrom
2015-08-21 15:34                       ` Dmitry A. Kazakov
2015-08-21 23:44                       ` Bob Duff
2015-08-22  6:22                         ` Dmitry A. Kazakov
2015-08-21 10:43                 ` Stefan.Lucks
2015-08-21 12:35                   ` Dmitry A. Kazakov
2015-08-24 21:32               ` Randy Brukardt
replies disabled

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