home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mole-end!mat
- From: mat@mole-end.matawan.nj.us
- Subject: Re: destruction of temporaries
- Message-ID: <1992Aug20.095429.29845@mole-end.matawan.nj.us>
- Summary: Not quite
- Organization: :
- References: <1992Aug17.073500.24115@ericsson.se> <23466@alice.att.com> <1992Aug20.092752.29529@mole-end.matawan.nj.us>
- Date: Thu, 20 Aug 1992 09:54:29 GMT
- Lines: 46
-
- 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:
- > > In article <1992Aug18.205211.16789@Warren.MENTORG.COM> adk@Warren.MENTORG.COM (Ajay Kamdar) writes:
- > >
- > > So why would the ARM consider the example with a temporary sufficient
- > > reason to reject the "end of function" approach? To me it appears that
- > > the "end of function" approach for temporaries would not cause any more
- > > difficulties or program bugs than those that can already occur even without
- > > temporaries. So why not reconsider that approach?
- >
- > > I don't want my temporaries to hang around until the end of the
- > > function. ...
-
- > > Temporaries should get destroyed as soon as their value has been used.
- > > To make call-by-reference a little more convenient, there is a special
- > > rule for binding references to temporaries, and I guess that's OK.
- . . .
- > 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?
-
- No, I'm wrong. It's not quite enough because of the conditional
- context. We have to specify the scope of the `thing' to which that
- value is bound in the conditional context.
-
- I'm inclined to say that it's the conditional part itself, just as
- in a function, the parameter is bound to something whose lifetime is
- that of the function, and any temporary expression can be destroyed
- thereafter.
-
- That, by the way, is different from the object created by the
- constructor here:
-
- int zot = Cthulu( 0 ).somefunc();
-
- The object created is voided after the member function call, or after
- that function call's value is bound to the initialization ...
-
- (Of course, that messes up member functions that return *this . ...)
- --
- (This man's opinions are his own.)
- From mole-end Mark Terribile
-
- mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
-