home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.eiffel
- Path: sparky!uunet!haven.umd.edu!purdue!ames!agate!spool.mu.edu!caen!uvaarpa!cv3.cv.nrao.edu!laphroaig!cflatter
- From: cflatter@nrao.edu (Chris Flatters)
- Subject: Re: Semantics of invariants
- Message-ID: <1992Dec16.163847.17559@nrao.edu>
- Sender: news@nrao.edu
- Reply-To: cflatter@nrao.edu
- Organization: NRAO
- References: <1992Dec15.213603.16406@bony1.bony.com>
- Date: Wed, 16 Dec 1992 16:38:47 GMT
- Lines: 26
-
- In article 16406@bony1.bony.com, richieb@bony1.bony.com (Richard Bielak) writes:
- >Is the invariant supposed to be true *ALL* the time, once the object is
- >created?
- >
- >If this is so, you can imagine each object having an "invariant-checker"
- >running continously on another processor.
- >
- >Or is it OK to invalidate the invariant while inside the object's routines,
- >as long as the invariant is true on exit.
-
- You can invalidate a class invariant inside a function or procedure
- provided that it is true on exit. In other words the class invariant
- is an implicit conjunct of both the precondition and the postcondition
- of a function or procedure. Suppose that the class invariant is I and
- the P is the precondition of a procedure of the class as given in the
- require clause and Q is the postcondition as given in the ensure clause:
- then (P and I) is also a precondition of the procedure and (Q and I) is
- also a postcondition of the procedure.
-
- If the values of class attributes are not modified outside of the procedures
- and functions of that class it is sufficient to check the class invariant
- on exit from each function or procedure since the invarient will not
- change between exit from one function/procedure and entry into the next.
-
- Chris Flatters
- cflatter@nrao.edu
-