comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Clayton <phil.clayton@lineone.net>
Subject: Re: Array initialization in SPARK
Date: Fri, 29 Oct 2010 18:04:23 -0700 (PDT)
Date: 2010-10-29T18:04:23-07:00	[thread overview]
Message-ID: <a3dd40b0-1d0c-4292-b982-b4c62a0dd017@u17g2000yqi.googlegroups.com> (raw)
In-Reply-To: eca9714d-6e0e-4c11-8e0a-afca76891e52@t13g2000yqm.googlegroups.com

On Oct 28, 5:38 pm, Phil Thornley <phil.jpthorn...@gmail.com> wrote:
> On 28 Oct, 17:26, Alexander Senier <m...@senier.net> wrote:
> [...]> It may be benificial to restrict the initialization to simple patterns
> > that could be verified (semi-)automatically in the future.
>
> [...]
>
> That's excellent advice.
>
> But if you can't do that, and it really is important to ensure
> complete initialization, and you are completing run-time check proofs,
> then you could force a check on the array:
>
> --# check for all I in Natural range Out_Matrix'Range(1) =>
> --#         (for J in Natural range Out_Matrix'Range(2) =>
> --#             (Out_Matrix(I, J) in Types.Float8));
>
> but, for a complex initialization, completing the proof of this check
> will be correspondingly complex :-(

Whilst concious of sounding like a broken record, I feel compelled to
mention that this is exactly one of the reasons "for aggregates" (as
discussed recently on c.l.a.) would be a useful new Ada feature.  We
could then write something like:

  Out_Matrix :=
     Matrix'(for I in Natural range Out_Matrix'Range(1) =>
               (for J in Natural range Out_Matrix'Range(2) =>
                  In_Matrix(J, I)));

Any tool doing static analysis (compilers included) would know from
the syntax that the whole of the l.h.s. is written to.  Also, for a
side-effect free r.h.s, it can be seen that the order of iteration
does not affect its value.

Phil Clayton



  reply	other threads:[~2010-10-30  1:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-28 10:13 Array initialization in SPARK Peter C. Chapin
2010-10-28 12:47 ` Phil Thornley
2010-10-28 14:51   ` Peter C. Chapin
2010-10-28 15:23     ` Peter C. Chapin
2010-10-28 16:26       ` Alexander Senier
2010-10-28 16:38         ` Phil Thornley
2010-10-30  1:04           ` Phil Clayton [this message]
2010-10-30  8:10             ` AdaMagica
2010-10-30 13:11               ` Phil Clayton
  -- strict thread matches above, loose matches on Subject: below --
2009-06-15 12:01 xorque
2009-06-15 12:10 ` xorque
replies disabled

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