home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18895 < prev    next >
Encoding:
Text File  |  1993-01-10  |  1.8 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!rational.com!thor!rmartin
  3. From: rmartin@thor.Rational.COM (Bob Martin)
  4. Subject: Re: Is it possible to use 'delete this' ?
  5. Message-ID: <rmartin.726675168@thor>
  6. Sender: news@rational.com
  7. Organization: Rational
  8. References: <rmartin.725129268@thor> <BzqE5s.6Lr@comp.vuw.ac.nz> <rmartin.725581109@thor> <C000qE.D3J@comp.vuw.ac.nz>
  9. Date: Sun, 10 Jan 1993 14:12:48 GMT
  10. Lines: 32
  11.  
  12. robertd@kauri.vuw.ac.nz (Robert Davies) writes:
  13.  
  14. |The problem I had with Bob's first reply was that he didn't answer the
  15. |question: is "delete this" legal.
  16.  
  17. To my knowledge, the syntax is legal.  (Steve Clamage:  Can you
  18. comment on legality?)
  19.  
  20. |Then it would be appropriate to give a warning. Incidentally, is the warning
  21. |about is causing difficulty to some compilers just a "gut feeling" or are
  22. |there specific examples?
  23.  
  24. No specific examples.  I give the warning because I have seen no words
  25. in the ARM to the effect that the code generated by the compiler must
  26. assume that the object may not exist during a member function call.
  27.  
  28. |Bob's warning about "delete this" seems to apply to any use of "delete" by
  29. |an entity that didn't do the corresponding "new". Otherwise there is always
  30. |the risk that the "delete" will be applied to something not created by
  31. |"new". Is this another safe programming rule?
  32.  
  33. No.  And my warning is only about the dangers of "delete this".
  34. "delete this" can only be appropriate for objects that are "always"
  35. allocated from the heap.  Unfortunately, there is no way for an object
  36. to insure this. 
  37.  
  38.  
  39. --
  40. Robert Martin                        Training courses offered in:
  41. R. C. M. Consulting                       Object Oriented Analysis
  42. 2080 Cranbrook Rd.                        Object Oriented Design
  43. Green Oaks, Il 60048 (708) 918-1004       C++
  44.