home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / mac / programm / 18573 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  1.6 KB

  1. Path: sparky!uunet!comp.vuw.ac.nz!waikato.ac.nz!ldo
  2. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Think Pascal - Whats... - data abstraction?
  5. Message-ID: <1992Nov18.172004.12287@waikato.ac.nz>
  6. Date: 18 Nov 92 17:20:04 +1300
  7. References: <6746@m1.cs.man.ac.uk> <1351@my.sm.luth.se>
  8. Organization: University of Waikato, Hamilton, New Zealand
  9. Lines: 32
  10.  
  11. In article <1351@my.sm.luth.se>, matti@my.sm.luth.se (Matti Larborn) writes:
  12. >
  13. > Another question: Why don't Think Pascal support abstract datatypes?
  14. >
  15. > The only thing they would have to add is an export declaration:
  16. >
  17. >     x=object
  18. >         export a,b; { or name it public if you like }
  19. >         a: integer;
  20. >         b: real;
  21. >         c: char; { hidden }
  22. >
  23. >         {?operations }
  24. >     end;
  25.  
  26. Why bother? There are too many potential complications with this scheme:
  27.  
  28. * What if you want the user to be able to read, but not write those fields?
  29. * What if you want the user to be able to write those fields in a certain
  30.   restricted fashion to preserve certain relationships to the values in
  31.   other fields?
  32. * What if you later decide not to store that field, but compute it from
  33.   some other fields? Changing this would break existing clients.
  34.  
  35. A simpler and more general approach is to define accessor procedures and
  36. functions. These can enforce any constraints you like. And they don't need
  37. a new language feature!
  38.  
  39. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  40. Computer Services Dept                     fax: +64-7-838-4066
  41. University of Waikato            electric mail: ldo@waikato.ac.nz
  42. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  43.