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: postconditions on creation procedures
- Message-ID: <1993Jan21.132817.1663@bony1.bony.com>
- Organization: multi-cellular
- References: <mod.727464101@cs.man.ac.uk>
- Date: Thu, 21 Jan 93 13:28:17 GMT
- Lines: 46
-
- In article <mod.727464101@cs.man.ac.uk> mod@cs.man.ac.uk (Mike O'Docherty (Teaching Company Associate)) writes:
- >On page 128 of "Eiffel: The Language", it is stated (in the definition of
- >consistency) that postconditions need not be checked on return from a
- >creation procedure. I see no reason why they they should be let off the hook;
- >is this a mistake?
- >
- >Mike.
- >
-
- Sounds like a mistake to me also. A creation procedure must establish
- the invariant, but it can also have its own pre- and postconditions.
- Here is a simple example:
-
- class CHECKING_ACCOUNT
- creation make
-
- feature{NONE}
-
- make (initial_deposit:INTEGER) is
- require
- initial_deposit > 100;
- do
- balance := initial_deposit
- ensure
- balance = initial_deposit
- end;
-
- [...stuff ommited...]
-
- invariant
-
- balance >= 0;
-
- end;
-
-
- ...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 - | *
-