home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / eiffel / 1443 < prev    next >
Encoding:
Text File  |  1993-01-21  |  1.6 KB  |  57 lines

  1. Newsgroups: comp.lang.eiffel
  2. Path: sparky!uunet!psinntp!bony1!richieb
  3. From: richieb@bony1.bony.com (Richard Bielak)
  4. Subject: Re: postconditions on creation procedures
  5. Message-ID: <1993Jan21.132817.1663@bony1.bony.com>
  6. Organization: multi-cellular
  7. References: <mod.727464101@cs.man.ac.uk>
  8. Date: Thu, 21 Jan 93 13:28:17 GMT
  9. Lines: 46
  10.  
  11. In article <mod.727464101@cs.man.ac.uk> mod@cs.man.ac.uk (Mike O'Docherty (Teaching Company Associate)) writes:
  12. >On page 128 of "Eiffel: The Language", it is stated (in the definition of 
  13. >consistency) that postconditions need not be checked on return from a
  14. >creation procedure. I see no reason why they they should be let off the hook;
  15. >is this a mistake?
  16. >
  17. >Mike.
  18. >
  19.  
  20. Sounds like a mistake to me also. A creation procedure must establish
  21. the invariant, but it can also have its own pre- and postconditions.
  22. Here is a simple example:
  23.  
  24. class CHECKING_ACCOUNT 
  25.         creation make
  26.  
  27. feature{NONE}
  28.  
  29.         make (initial_deposit:INTEGER) is
  30.                 require
  31.                         initial_deposit > 100;
  32.                 do
  33.                         balance := initial_deposit
  34.                 ensure
  35.                         balance = initial_deposit
  36.                 end;
  37.  
  38. [...stuff ommited...]
  39.  
  40. invariant
  41.  
  42.         balance >= 0;
  43.  
  44. end;
  45.  
  46.  
  47. ...richie
  48.  
  49.  
  50.  
  51.  
  52. -- 
  53. * Richie Bielak   (212)-815-3072   |                                          *
  54. * Internet:       richieb@bony.com | Rule #1: Don't sweat the small stuff.    *
  55. * Bang {uupsi,uunet}!bony1!richieb | Rule #2: It's all small stuff.           *
  56. *    - Strictly my opinions -      |                                          *
  57.