home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.eiffel
- Path: sparky!uunet!psinntp!bony1!richieb
- From: richieb@bony1.bony.com (Richard Bielak)
- Subject: Re: Semantics of invariants
- Message-ID: <1992Dec17.190450.24798@bony1.bony.com>
- Organization: multi-cellular
- References: <1992Dec15.213603.16406@bony1.bony.com> <1992Dec16.163847.17559@nrao.edu>
- Date: Thu, 17 Dec 92 19:04:50 GMT
- Lines: 55
-
- In article <1992Dec16.163847.17559@nrao.edu> cflatter@nrao.edu writes:
- >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?
-
- [...]
-
- >
- >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.
- >
-
- [...]
-
- OK. I understand all this, but consider this situation (in pseudo-Eiffel):
-
- class FOO is
- export r1, r2
-
- r1 is
- do
- [...do something here to make the invariant false...]
- r2;
- end; -- r1
-
- r2 is
- do
- [... some stuff ...]
- end; -- r2
-
- invariant
- inv_condition
-
- end; -- FOO
-
-
- If we have "x" of type FOO, does the call "x.r1" work or does it fail?
- Note that the invariant is false, when routine "r2" is called.
-
- One way to deal with this is to insist that the invariant should
- always be true - I mean it is an *INVARIANT*.
-
- ...richie
-
- --
- * Richie Bielak (212)-815-3072 | *
- * Internet: richieb@bony.com | Rule #1: Don't sweat the small stuff. *
- * Bang {uupsi,uunet}!bony1!richieb | Rule #2: It's all small stuff. *
- * - Strictly my opinions - | *
-