home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 12991 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  1.5 KB

  1. Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: destruction of temporaries
  5. Message-ID: <TMB.92Aug27223753@arolla.idiap.ch>
  6. Date: 28 Aug 92 02:37:53 GMT
  7. References: <TMB.92Aug21160625@arolla.idiap.ch> <28619@vedge.UUCP>
  8. Sender: news@ai.mit.edu
  9. Reply-To: tmb@idiap.ch
  10. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  11.     Perceptive)
  12. Lines: 33
  13. In-reply-to: hendrik@vedge.UUCP's message of 26 Aug 92 13:42:47 GMT
  14.  
  15. In article <28619@vedge.UUCP> hendrik@vedge.UUCP (Hendrik Boom) writes:
  16.  
  17.    tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
  18.    : 
  19.    : Under either rule, expressions can already be rewritten to obtain the
  20.    : desired lifetime. For example:
  21.    : 
  22.    :     X result = x.a().b().c().d();
  23.    : 
  24.     [...]
  25.    : 
  26.    : Language: late destruction, Wanted: early destruction:
  27.    : 
  28.    :     X a = x.a();
  29.    :     X b = a.b();
  30.    :     destroy(a);
  31.    :     X c = b.c();
  32.    :     destroy(b);
  33.    :     X result = c.d();
  34.    :     destroy(c);
  35.    : 
  36.    What is 'destroy'? Some language feature I don't know about that
  37.    isn't in the ARM syntax?  Or a user-defined member funtion that has
  38.    no control over the calling of the actual destructors of members
  39.    of a, b, and c?
  40.  
  41. "destroy(x);" is whatever you want to do to destroy "x". Usually,
  42. "destroy(x);" will _not_ simply be a call to the destructor, since
  43. most destructors will do odd things when called twice on the same
  44. object (in code like "{X x; x.X::~X();}", the destructor for "x" will
  45. get called twice).
  46.  
  47.                     Thomas.
  48.