home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12388 < prev    next >
Encoding:
Text File  |  1992-08-15  |  3.0 KB  |  68 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Garbage Collection for C++
  5. Message-ID: <1992Aug16.054519.25393@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <DAVEG.92Aug13025629@synaptx.synaptics.com> <1992Aug14.021547.15215@news.mentorg.com> <DAVEG.92Aug14194411@synaptx.synaptics.com>
  10. Date: Sun, 16 Aug 1992 05:45:19 GMT
  11. Lines: 55
  12.  
  13. In article <DAVEG.92Aug14194411@synaptx.synaptics.com> daveg@synaptics.com (Dave Gillespie) writes:
  14. >In article <1992Aug14.021547.15215@news.mentorg.com> bcannard@hppcb36.mentorg.com (Bob Cannard @ PCB x5565) writes:
  15.  
  16. >I still think declaring pointers to be GC would be too much of a
  17. >hassle for the programmer, so we're left having to assume all
  18. >pointers may point to GC-allocated objects.  
  19.  
  20.     Thats why GC on a class basis. A pointer to a GC class
  21. IS a GC pointer, there's no need for the programmer to 'declare'
  22. it as such.
  23.  
  24.     GC class X { .... // GC collectable class
  25.     X* p;    // GC pointer because X is GC, no special syntax
  26.  
  27.  
  28. >Without adding lots of
  29. >tags in places that make C compatiblity awkward, we're left with a
  30. >completely "conservative", i.e., brute-force GC algorithm.  We scan
  31. >every word on the stack, every word in static storage, and every
  32. >word on the non-GC heap for things that look like GC pointers.
  33.  
  34.     It wont work under Windows.
  35. There is no stack, except temporarily on member function calls.
  36. The objects are rooted directly in the window memory, and the're
  37. looked after by the OS, not the stack.
  38.  
  39.     The C memory model is defunct. This is the biggest flaw
  40. in C/C++. C memory model assumes three segments: code, data, stack.
  41. (Pascal assume two, code and stack). We can tack on the heap for
  42. C++ because it has a built in 'new' operator. To implement
  43. persistence, dynamic linkage, multi-tasking with shared memory,
  44. ROM, hardware ports, etc, requires language support. 
  45. (Oh, C has register too)
  46.  
  47.     If you look at the Windows memory model you will see what I mean.
  48. It requires truly awful C to manage, and C++ cant help much.
  49. Windows uses handles, and you have to lock them to get out a pointer.
  50. The memory can be moved when the handle is not locked. And you had
  51. better unlock them after you're finished.
  52.  
  53.     Smart pointers can be used to do the lock automatically,
  54. but I cant see how the unlock can be done, operator-> just
  55. isn't smart enough. Basically, the C/C++ memory model doesn't
  56. support handles, and so NO amount of cleverness can convince
  57. the system to support handles. You have to do it by hand.
  58.  
  59.     Anyhow, looking GC certainly raises some interesting 
  60. questions. It generally get implemented in systems with a controlled
  61. run-time environment, which definitely isnt C++.
  62.  
  63. -- 
  64. ;----------------------------------------------------------------------
  65.         TIM (TAL) LISTER,         maxtal@extro.ucc.su.oz.au
  66.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  67. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  68.