home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: destruction of temporaries
- Message-ID: <TMB.92Aug27223753@arolla.idiap.ch>
- Date: 28 Aug 92 02:37:53 GMT
- References: <TMB.92Aug21160625@arolla.idiap.ch> <28619@vedge.UUCP>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 33
- In-reply-to: hendrik@vedge.UUCP's message of 26 Aug 92 13:42:47 GMT
-
- In article <28619@vedge.UUCP> hendrik@vedge.UUCP (Hendrik Boom) writes:
-
- tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
- :
- : Under either rule, expressions can already be rewritten to obtain the
- : desired lifetime. For example:
- :
- : X result = x.a().b().c().d();
- :
- [...]
- :
- : Language: late destruction, Wanted: early destruction:
- :
- : X a = x.a();
- : X b = a.b();
- : destroy(a);
- : X c = b.c();
- : destroy(b);
- : X result = c.d();
- : destroy(c);
- :
- What is 'destroy'? Some language feature I don't know about that
- isn't in the ARM syntax? Or a user-defined member funtion that has
- no control over the calling of the actual destructors of members
- of a, b, and c?
-
- "destroy(x);" is whatever you want to do to destroy "x". Usually,
- "destroy(x);" will _not_ simply be a call to the destructor, since
- most destructors will do odd things when called twice on the same
- object (in code like "{X x; x.X::~X();}", the destructor for "x" will
- get called twice).
-
- Thomas.
-