home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!mintaka.lcs.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.92Aug21160625@arolla.idiap.ch>
- Date: 21 Aug 92 20:06:25 GMT
- Article-I.D.: arolla.TMB.92Aug21160625
- References: <1992Aug17.073500.24115@ericsson.se> <23466@alice.att.com>
- <TMB.92Aug19113657@arolla.idiap.ch>
- <1992Aug20.092752.29529@mole-end.matawan.nj.us>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 47
- In-reply-to: mat@mole-end.matawan.nj.us's message of 20 Aug 92 09:27:52 GMT
-
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: destruction of temporaries
- Date: 21 Aug 92 18:45:56 GMT
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- In-reply-to: mat@mole-end.matawan.nj.us's message of 20 Aug 92 09:27:52 GMT
-
- In article <1992Aug20.092752.29529@mole-end.matawan.nj.us> mat@mole-end.matawan.nj.us writes:
-
- In article <TMB.92Aug19113657@arolla.idiap.ch>, tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
- Here's a thought. There was, at one time, a suggestion for an `operator
- void()' that describes the action of throwing away a value. It gets used
- for anything except the intialization of an object. Would the `operator
- void()' concept describe the point at which the temporary must be
- discarded?
-
- Under either rule, expressions can already be rewritten to obtain the
- desired lifetime. For example:
-
- X result = x.a().b().c().d();
-
- Language: early destruction, Wanted: late destruction:
-
- X a = x.a();
- X b = a.b();
- X c = b.c();
- X result = 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);
-
- The question is: what should be the default. I don't think that
- mandatory late destruction solves anything, because if you start
- relying on the persistence of temporaries in expressions, the next
- step is that you'll get confused about why they don't hang around for
- the whole block.
-
- Thomas.
-