home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / std / cplus / 1100 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  1.5 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!allegra!alice!ark
  2. From: ark@alice.att.com (Andrew Koenig)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: this == 0 for nonvirtual functions
  5. Keywords: this virtual function undefined
  6. Message-ID: <23512@alice.att.com>
  7. Date: 21 Aug 92 14:30:01 GMT
  8. Article-I.D.: alice.23512
  9. References: <1992Aug18.045605.14220@sunb10.cs.uiuc.edu> <1992Aug20.215455.17279@microsoft.com> <1992Aug21.044448.8282@sunb10.cs.uiuc.edu>
  10. Reply-To: ark@alice.UUCP ()
  11. Distribution: usa
  12. Organization: AT&T Bell Laboratories, Murray Hill NJ
  13. Lines: 24
  14.  
  15. Perhaps someone might like to try to construct an example of why
  16. it might actually be useful to allow this==0 in a member function.
  17. I've been away, so I've missed some messages, but so far the only
  18. justification I've seen is statement like `it seems like a good idea.'
  19.  
  20. I find it hard to imagine why it would be useful.  A member function
  21. that never looks at `this' could just as well be made static;
  22. one that actually uses `this' had better not be called with this==0.
  23. Thus it appears that the only useful cases are:
  24.  
  25.     1. a function that actually checks if this==0 and does different
  26.        things depending on the result, or
  27.  
  28.     2. a function that looks at this only if one of its arguments has
  29.        a particular value.
  30.  
  31. Both of these cases seem contrived to me, to the extent that I would
  32. expect to be able to accomplish an equivalent thing more elegantly by
  33. other means.
  34.  
  35. Can someone actually come with a useful example?
  36. -- 
  37.                 --Andrew Koenig
  38.                   ark@europa.att.com
  39.