comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <jspa@nykredit.dk>
Subject: SPARK and static unit checking?
Date: Fri, 11 Apr 2008 02:59:20 -0700 (PDT)
Date: 2008-04-11T02:59:20-07:00	[thread overview]
Message-ID: <af9b42f7-b24c-4ca5-8a49-1ea9c15e1f37@y21g2000hsf.googlegroups.com> (raw)

I have found a rather annoying (but in some ways very reasonable) rule
in SPARK:

   You are not allowed to (re)declare operators for a type.

This prevents me from using my standard trick for static unit type
checking:

   type Length is private;
   function "+" (L, R : Length) return Length; -- not SPARK
   ...
   Meter : constant Length;

   type Area is private;
   function "*" (L, R : Length) return Area; -- not SPARK
   ...

I have an idea for a (clumsy) solution:  Generate two packages with
the same types (name-wise).  The one as above, the other simply as:

   type Length is new Float;
   type Area is new Float;

Then I can use the liberal version with the SPARK tools, and swap the
restrictive in for the proper compilation.

Any proposals for an elegant solution?

Jacob
--
[ I left my signature generator at home. ]



             reply	other threads:[~2008-04-11  9:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-11  9:59 Jacob Sparre Andersen [this message]
2008-04-13 19:39 ` SPARK and static unit checking? JP Thornley
2008-04-14 11:21   ` Jacob Sparre Andersen
2008-04-14 14:57     ` roderick.chapman
replies disabled

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