home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!van-bc!rsoft!agate!ames!elroy.jpl.nasa.gov!usc!wupost!gumby!yale!mintaka.lcs.mit.edu!bloom-beacon!eru.mt.luth.se!lunic!sunic!lth.se!newsuser
- From: dag@control.lth.se (Dag Bruck)
- Newsgroups: comp.lang.c++
- Subject: Re: destruction of temporaries
- Message-ID: <1992Aug19.111836.25070@lth.se>
- Date: 19 Aug 92 11:18:36 GMT
- References: <1992Aug17.073500.24115@ericsson.se> <23466@alice.att.com> <1992Aug17.211508.6634@lucid.com> <1992Aug18.205211.16789@Warren.MENTORG.COM> <TMB.92Aug19113657@arolla.idiap.ch>
- Sender: newsuser@lth.se (LTH network news server)
- Organization: Department of Automatic Control, Lund, Sweden
- Lines: 25
-
- In <comp.lang.c++> tmb@idiap.ch writes:
- >The properties of temporaries are no different (and no worse) than the
- >properties of automatic variables: pointers to them become invalid
- >when the object disappears.
-
- I think there is a major difference. The programmer controls the
- scope of automatic variables and hence their lifetime. Temporaries
- are created by the compiler (possibly because of ill-advised
- programming techniques) and the programmer has no control over their
- lifetime.
-
- The language does not specify under what circumstances temporaries are
- created, and I'm willing to accept that, but it should at least
- specify their lifetime in expressions that potentially create
- temporaries.
-
- Given the deliberations for and against different models [no details
- given] I would probably prefer destruction at greatest enclosing
- expression, with the additional constraint that temporaries created in
- one "arm" of a conditional expression are destroyed at the end of that
- conditional expression.
-
- With respect to difficulty of implementation, in particular combined
- with exception handling, it would probably pay off to look at existing
- implementations (I can think of HP and IBM) before making any judgements.
-