Building High Integrity Applications with Spark by McCormick John W. & Chapin Peter C

Building High Integrity Applications with Spark by McCormick John W. & Chapin Peter C

Author:McCormick, John W. & Chapin, Peter C.
Language: eng
Format: epub
Publisher: Cambridge University Press
Published: 2015-08-30T16:00:00+00:00


The only change relative to the earlier Shapes3 package is that the condition on the circle being in the workspace has been moved from being a precondition of Inside_Circle and a postcondition of Make_Circle to being an invariant of the Circle private type. Notice that in the expression used for the type invariant the name of the type itself, Circle , is used as a stand-in for the object of that type being checked.

Type invariants can only be applied to private types. The condition they assert is only enforced at the “boundary” of the package that implements the type. Inside that package, objects may go through intermediate states where the invariant is temporarily false. However, the invariant is checked whenever a public subprogram returns to ensure that objects seen by the clients of the package are always in a proper state. In this respect, type invariants are somewhat like postconditions that are automatically applied to all public subprograms. Because SPARK does not currently support type invariants, their effect could be simulated, in large measure, by tediously defining appropriate postconditions.

Package Shapes4 as currently defined provides no default initialization for a Circle object. Merely declaring a Circle may cause the type invariant to fail as type invariants are also checked after default initialization and the initial values of the components of a Circle are indeterminate.

Sensible default initialization can be specified by simply adding appropriate initializers to the components of the record defining Circle :



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.