comp.lang.ada
 help / color / mirror / Atom feed
* The future of Spark . Spark 2014 : a wreckage
@ 2013-07-08 17:56 vincent.diemunsch
  2013-07-08 19:24 ` Simon Wright
                   ` (3 more replies)
  0 siblings, 4 replies; 68+ messages in thread
From: vincent.diemunsch @ 2013-07-08 17:56 UTC (permalink / raw)


Have you heard of the new Spark 2014 initiative by AdaCore ?
http://docs.adacore.com/spark2014-docs/html/ug/language_subset.html

Spark 2014 aims at replacing Spark annotations by Ada 2012 aspects, at replacing proof functions by expression functions, and at using the Frama-C
tools (Alt-Ergo and why3 language) for automatic proof. At the beginning I thought this was a good idea, but the more I get into the subject, the more it seems for me that they are going wrong.

First ASPECTS : Let's take an example, that is given in the Spark Reference Manual.

- their syntax is clumsy and error prone : 

Spark 2005 :
   procedure Swap;
   --# global in out X, Y;
   --# derives X from Y &
   --#         Y from X;
  
Same specification in Spark 2014 :
   procedure Swap
      with Global  => (In_Out => (X, Y)),
           Depends => (X => Y,   -- to be read as "X depends on Y"
                       Y => X);  -- to be read as "Y depends on X"

How are we supposed to guess that "X => Y" means X depends on Y, if the arrow goes from X to Y ? In the literature, Flow analysis use always Information Flow where arrows follows the real move of information. See for instance "SPARK the proven approach of High Integrity Software" from John Barn page 311 or the "Dragon Book" (Compilers : principles, techniques and tools).

- the syntax makes a complete confusion between a precondition and a test : Preconditions are SPECIFICATIONS that insures that the runtime tests that the Ada compiler puts in the code will pass. What's the use of testing at the entry of a procedure what will be tested in the procedure ? Doing the test twice won't impove correctness ! That is why proconditions and postconditions must stay as comments.


Second EXPRESSION FUNCTIONS :

Expressions functions break the Ada Specification, by allowing the programmer to give the body of a function into the specification of a package. For what purpose ? To allow the runtime testing of pre and post conditions...

But Spark had logical functions that could be declared in the package specification, for expressing pre/postconditions, for instance : 
   --# type StackType is abstract;
   --# function Count_of(S: StackType) return Natural;
   --# function Substack(S1: StackType; S2: StackType) return Boolean;

The problem with Spark was that one had to use an old language : FDL to express
what these functions meant. So the only thing that is required here for an improvement of Spark is to be able to write IN THE PACKAGE BODY the logical function as, for instance : 

package body Stack
--# own State is Ptr, Vector;

is
   type Ptrs       is range 0..MaxStackSize;
   subtype Indexes is Ptrs range 1..Ptrs'Last;
   type Vectors    is array (Indexes) of Integer;

   Ptr      : Ptrs    := 0;
   Vector   : Vectors := Vectors'(Indexes => 0);
   
   --# function Count_of(S: StackType) return Natural is Ptr;
   --# function Substack(S1: StackType; S2: StackType) return Boolean is
   --#    (for all X in 1 .. S1.Ptr => S1.Vector(X) = S2.Vector(X));

This is much, much better than the Spark 2014 solution because :
- a proof function like Substack is not supposed to be called at runtime, because it compares to states of the same unique stack, not two real stacks ! so it should not appear in the compilable code. But Spark 2014 would transform this into a runtime comparison...
- it allows to do in the body a refinement of the abstract type Stacktype that represents the package state, which is not possible with expression functions in the specification. It seems that the people of Spark 2014 didn't get that point.

I realy hope that Spark users will say to AdaCore that they aro going wrong and that AdaCore will really try to make a better future for Spark.

Vincent DIEMUNSCH

^ permalink raw reply	[flat|nested] 68+ messages in thread

end of thread, other threads:[~2013-08-05  5:43 UTC | newest]

Thread overview: 68+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-08 17:56 The future of Spark . Spark 2014 : a wreckage vincent.diemunsch
2013-07-08 19:24 ` Simon Wright
2013-07-08 20:59 ` Florian Weimer
2013-07-09  7:40   ` Dmitry A. Kazakov
2013-07-09  8:30     ` Georg Bauhaus
2013-07-09  8:58       ` Dmitry A. Kazakov
2013-07-09 10:27         ` G.B.
2013-07-09 11:13         ` G.B.
2013-07-09 15:14     ` Adam Beneschan
2013-07-09 22:51     ` Robert A Duff
2013-07-10  7:49       ` Dmitry A. Kazakov
2013-07-10  8:21         ` Georg Bauhaus
2013-07-08 21:32 ` Randy Brukardt
2013-07-09  7:28   ` Dmitry A. Kazakov
2013-07-09 11:29     ` Simon Wright
2013-07-09 12:22       ` Dmitry A. Kazakov
2013-07-09 20:37     ` Randy Brukardt
2013-07-10 10:03       ` Dmitry A. Kazakov
2013-07-10 23:21         ` Randy Brukardt
2013-07-11  7:44           ` Dmitry A. Kazakov
2013-07-11 22:28             ` Randy Brukardt
2013-07-12  8:02               ` Dmitry A. Kazakov
2013-07-12 21:16                 ` Randy Brukardt
2013-07-14 10:19                   ` Dmitry A. Kazakov
2013-07-14 15:57                     ` Georg Bauhaus
2013-07-16  0:16                       ` Randy Brukardt
2013-07-17  1:30                         ` Shark8
2013-07-17 23:08                           ` Randy Brukardt
2013-07-18  7:19                             ` Dmitry A. Kazakov
2013-07-19  4:36                               ` Randy Brukardt
2013-07-16  0:13                     ` Randy Brukardt
2013-07-16  8:37                       ` Dmitry A. Kazakov
2013-07-16 22:13                         ` Randy Brukardt
2013-07-17  7:59                           ` Dmitry A. Kazakov
2013-07-17 23:26                             ` Randy Brukardt
2013-07-18  7:37                               ` Dmitry A. Kazakov
2013-07-19  4:32                                 ` Randy Brukardt
2013-07-19  7:16                                   ` Dmitry A. Kazakov
2013-07-20  5:32                                     ` Randy Brukardt
2013-07-20  9:06                                       ` Dmitry A. Kazakov
2013-07-12  1:01           ` Slow? Ada?? Bill Findlay
2013-07-09  7:57   ` The future of Spark . Spark 2014 : a wreckage Stefan.Lucks
2013-07-09 20:46     ` Randy Brukardt
2013-07-10  8:03       ` Stefan.Lucks
2013-07-10 12:46         ` Simon Wright
2013-07-10 23:10         ` Randy Brukardt
2013-07-11 19:23           ` Stefan.Lucks
2013-07-12  0:21             ` Randy Brukardt
2013-07-12  9:12               ` Stefan.Lucks
2013-07-12 20:47                 ` Randy Brukardt
2013-08-05  5:43                 ` Paul Rubin
2013-07-10 12:19   ` vincent.diemunsch
2013-07-10 16:02     ` Simon Wright
2013-07-11  0:36     ` Randy Brukardt
2013-07-11  6:19       ` Simon Wright
2013-07-11 23:11         ` Randy Brukardt
2013-07-11 10:10       ` vincent.diemunsch
2013-07-11 14:23         ` Dmitry A. Kazakov
2013-07-12  0:07           ` Randy Brukardt
2013-07-12  0:00         ` Randy Brukardt
2013-07-12  7:25           ` Simon Wright
2013-07-12 20:07             ` Randy Brukardt
2013-07-12 14:23           ` Robert A Duff
2013-07-12 20:14             ` Randy Brukardt
2013-07-11 23:50       ` Shark8
2013-07-08 23:18 ` Peter C. Chapin
2013-07-09  7:34   ` Stefan.Lucks
2013-07-09 15:21     ` Adam Beneschan

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