home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / modula3 / 1150 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  3.7 KB

  1. Path: sparky!uunet!gatech!udel!darwin.sura.net!spool.mu.edu!hri.com!noc.near.net!nic.umass.edu!nic.umass.edu!hudson
  2. From: hudson@cs.umass.edu (Rick Hudson)
  3. Newsgroups: comp.lang.modula3
  4. Subject: Re: references, objects & m3
  5. Message-ID: <HUDSON.93Jan25170041@yough.cs.umass.edu>
  6. Date: 25 Jan 93 22:00:41 GMT
  7. References: <C1BsMI.5Ay@undergrad.math.waterloo.edu> <MOSS.93Jan24164146@CRAFTY.cs.cmu.edu>
  8.     <C1E30F.vx@undergrad.math.waterloo.edu>
  9.     <FN00.93Jan25085601@tahoe.gte.com> <24699@alice.att.com>
  10. Reply-To: hudson@cs.umass.edu
  11. Organization: Dept of Comp and Info Sci, Univ of Mass (Amherst)
  12. Lines: 54
  13. NNTP-Posting-Host: yough.ucc.umass.edu
  14. In-reply-to: ark@alice.att.com's message of 25 Jan 93 19:35:20 GMT
  15.  
  16. >>>>> On 25 Jan 93 19:35:20 GMT, ark@alice.att.com (Andrew Koenig) said:
  17. AK> Article-I.D.: alice.24699
  18.  
  19. AK> In article <FN00.93Jan25085601@tahoe.gte.com> fn00@gte.com (Farshad Nayeri) writes:
  20.  
  21. > - Because of garbage collection, destructors are not as crucial in
  22. >   Modula-3 programming. (What do you usually do in a destructor in
  23. >   C++?)
  24.  
  25. AK> If C++ had garbage collection, destructors would sometimes still be
  26. AK> useful.  For example, if I have an object that represents a window in
  27. AK> my window system, I really do want the window to go away as soon as
  28. AK> the object is no longer in use, rather than waiting around for the
  29. AK> next garbage collection.  A similar argument applies to flushing the
  30. AK> buffer of an I/O library structure as soon as possible.
  31.  
  32. True, see Barry Hayes's survey paper "Finalization ion the Collector
  33. Interface" in the last International Workshop on Memory Management (Springer
  34. Verlag LNCS 637) for a discussion of the issues.
  35.  
  36. One advantage M3 has over some of the other languages that have GC and want
  37. finalization is that M3 has threads. This means that once the semantics of
  38. what should be finalized is worked out the semantics of when are simple.  I
  39. suspect that registering objects for finalization might be the easiest
  40. semantic for determining what objects should be finalized. This could be
  41. accomplished by passing the object to some system REGISTER_TO_FINALIZE
  42. routine. When the GC discovers such a registered object is no longer
  43. accessible, it passes the object to the finalization thread for finalization
  44. sometime in the future.  Notice that finalization doesn't actually DISPOSE of
  45. the memory used by the object it just performs actions like flushing buffers
  46. and closing files. The GC will dispose of the memory. This solves the problem
  47. of whether a finalization routine can resurrect an object, it can and it could
  48. even register the object to be finalized again.
  49.  
  50. This leaves only one issue to wrap up and that is the order that linked
  51. objects are finalized. One would not like to close a file prior to flushing
  52. the IO buffer for example. I once thought that objects should be finalized in
  53. reverse order of creation since this seems to follow C++ and Ada 9X
  54. conventions. Recently, I have come to believe that this will put undo
  55. restrictions on some GC schemes. Someone (Greg Nelson??) suggested that
  56. one way around these restrictions is to not finalize objects that are linked.
  57. Data structures that hold information needed for finalization would have to be
  58. hung off of any objects that form a circularity. In other words there could be
  59. no path from one finalizable object to another finalizable object. This seemed
  60. like a very simple solution that would require very little rethinking of data
  61. structures on the programmers part.
  62.  
  63. --
  64.  
  65.        Richard L. Hudson  -  Hudson@cs.umass.edu; (413) 545-1220; 
  66.        Advanced Languages Project - University Computing Services
  67.        Lederle Graduate Research Center
  68.        University of Massachusetts             Amherst, MA  01003
  69.        "Unix and C are the ultimate computer viruses." - R. Gabriel
  70.