comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Can't work out how to use with Ada.Numerics.Discrete_Random with SPARK 2014
Date: Fri, 30 Jun 2017 08:28:27 +0100
Date: 2017-06-30T08:28:27+01:00	[thread overview]
Message-ID: <lyvane2auc.fsf@pushface.org> (raw)
In-Reply-To: e3a88437-89a9-4feb-9780-1b06ca32e033@googlegroups.com

digitig <digitig@gmail.com> writes:

> package body Main
> with SPARK_Mode => On
> is
>    procedure Test is
>       subtype Die is Integer range 1 .. 6;
>       subtype Dice is Integer range 2*Die'First .. 2*Die'Last;
>       package Random_Die is new Ada.Numerics.Discrete_Random (Die);

(SPARK GPL 2017) move these declarations up to package level .. then,

>       use Random_Die;
>       G : Generator;

 "Generator" is not allowed in SPARK
 violation of aspect SPARK_Mode at line xx

>       D : Dice;
>    begin
>       Reset (G);  -- Start the generator in a unique state in each run
>       loop
>          -- Roll a pair of dice; sum and process the results
>          D := Random(G) + Random(G);

 "Result_Subtype" is not allowed in SPARK
 violation of aspect SPARK_Mode at line xx

>          Ada.Text_IO.Put_Line(D'Image);
>       end loop;
>    end Test;
> end Main;

  reply	other threads:[~2017-06-30  7:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30  1:15 Can't work out how to use with Ada.Numerics.Discrete_Random with SPARK 2014 digitig
2017-06-30  7:28 ` Simon Wright [this message]
2017-06-30 11:38   ` digitig
replies disabled

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