🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #768

Re: Order of destructor calls for auto objects

#768
From: Dag Bruck
Date: Sun, 23 Dec 1990 16:31
39 lines
2240 bytes
In article <1990Dec21.192649.1100@sjsumcs.sjsu.edu> horstman@sjsumcs.SJSU.EDU (Cay Horstmann) writes:
>In article <1990Dec20.074232.9416@lth.se> dag@control.lth.se (Dag Bruck) writes:
>>
>>The idea is that creating a Lock object allocates some resource, which
>>is then freed when the Lock object is destroyed.
>
>FURTHERMORE, it is also very important that objects get destroyed AS SOON
>AS POSSIBLE. Many current implementations do not do that--unused objects,
>especially temporary objects, may linger for quite a while. 

Well, "as soon as possible" may not be the ultimate goal for real-time
programmers; the most important requirement is that it SHOULD BE
DEFINED!

You can imagine several alternatives:

	1.  As soon as possible.
	2.  At the end of the current expression.
	3.  At end of statement.
	4.  At end of block.
	5.  At end of function.

Only #5 is completely useless.  I think my personal bias is for #2 or
#3, but this has to discussed further.  The reason why #1 is not the
best alternative is that it reduces the opportunity for optimization (so
I believe); I have also heard the argument that it would break a lot
of existing code that bends the rules slightly.

The standard should also specify when a temporary may be created; this
is natural requirement that often gets overlooked in the debate.

And finally, Merry Christmas and a Happy New Year.

Dag M Bruck
--
Department of Automatic Control		E-mail: dag@control.lth.se
Lund Institute of Technology
P. O. Box 118				Phone:	+46 46-104287
S-221 00 Lund, SWEDEN			Fax:    +46 46-138118
Technical Details
Message-ID: <1990Dec23.163113.25083@lth.se>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!mintaka!yale!cmcl2!uupsi!sunic!lth.se!newsuser
References: <1990Dec14.221247.9487@lia> <martino.661601979@krypton> <1990Dec20.074232.9416@lth.se> <1990Dec21.192649.1100@sjsumcs.sjsu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!mintaka!yale!cmcl2!uupsi!sunic!lth.se!newsuser
From: dag@control.lth.se (Dag Bruck)
Newsgroups: comp.std.c++
Subject: Re: Order of destructor calls for auto objects
Message-ID: <1990Dec23.163113.25083@lth.se>
Date: 23 Dec 90 16:31:13 GMT
References: <1990Dec14.221247.9487@lia> <martino.661601979@krypton> <1990Dec20.074232.9416@lth.se> <1990Dec21.192649.1100@sjsumcs.sjsu.edu>
Sender: newsuser@lth.se (LTH network news server)
Organization: Department of Automatic Control, Lund, Sweden
Lines: 39