home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: destruction of temporaries
- Message-ID: <1992Aug21.010755.17454@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Aug18.205211.16789@Warren.MENTORG.COM> <TMB.92Aug19113657@arolla.idiap.ch> <1992Aug19.111836.25070@lth.se>
- Date: Fri, 21 Aug 1992 01:07:55 GMT
- Lines: 54
-
- In article <1992Aug19.111836.25070@lth.se> dag@control.lth.se (Dag Bruck) writes:
- >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,
-
- Do you mean the next semicolon? I think thats what
- you just said isn't it?
-
- >with the additional constraint that temporaries created in
- >one "arm" of a conditional expression are destroyed at the end of that
- >conditional expression.
-
- As a matter of interest, what is the status of
-
- (a<b ? a : b )=1;
-
- If a and b were just integers, they would need to be construed as
- lvalues for the above to make any sense. But that is not
- true for classes where the concept of lvalue is not so well
- defined. It is possible if not sensible to assign a value
- to a temporary class object and obtains a persistent
- result through side effects. Because assignment has no
- special status for class objects.
- >
- >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.
-
- Desstroying temporaries at the right time seems not so hard.
- Defining the right time is harder (if not impossible without GC).
- And making exceptions work is harder still (since RTTI is required
- in their present form)
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-