Path: utzoo!attcan!uunet!olivea!decwrl!sun-barr!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!samsung!rex!uflorida!travis!tom From: tom@ssd.csd.harris.com (Tom Horsley) Newsgroups: comp.lang.c++ Subject: Re: Smart pointers and stupid people (was: garbage collection...) Message-ID: Date: 28 Jan 91 13:26:17 GMT References: <4127@osc.COM> <3344@lupine.NCD.COM> <4174@osc.COM> Sender: news@travis.csd.harris.com Distribution: comp Organization: Harris Computer Systems Division Lines: 44 In-reply-to: tma@osc.COM's message of 26 Jan 91 08:47:22 GMT >>>>> Regarding Re: Smart pointers and stupid people (was: garbage collection...); tma@osc.COM (Tim Atkins) adds: tma> Obviously, generated results can be and often are stored away by compiler tma> generated code even without counting optimization for later use in any tma> context where it can be determined by the compiler that any depended on tma> values are constant in particular. "...where it can be determined by the compiler that any depended on values are constant..." This is the key point. No compiler with any brains keeps something in a register across a function call where that something might be aliased. The question then becomes, how does the compiler find out the thing is aliased? tma> Now, if I call something that causes the object to move, then these tma> stored away pointers are now invalid. However, HOW DOES THE COMPILER tma> know? I don't know of any way to make it know this strictly from the tma> language end. True a compiler can be built that does makes this possible. This is the other key point. How do you make sure that 'this' is also a "smart pointer" so the compiler will know it had its address taken and know it is aliased? Without changes to the language (which is what most of this discussion seems to have been about in the first place) this is that hard part, with changes to the language it is not all that difficult, you simply need 'this' to be some kind of "smart pointer" as well as all the other pointers that are laying around. The only way (without language changes) seems to be following a coding convention that will avoid ever having 'this' move. As someone pointed out early in this thread (it seems like years ago now) this can be done by always using an extra level of indirection so 'this' is not actually in the heap and is not garbage collected. This involves extra overhead for the indirection and the coding style is cumbersome and easy to get wrong, which is why so many people are talking about changes to the language. -- ====================================================================== domain: tahorsley@csd.harris.com USMail: Tom Horsley uucp: ...!uunet!hcx1!tahorsley 511 Kingbird Circle Delray Beach, FL 33444 +==== Censorship is the only form of Obscenity ======================+ | (Wait, I forgot government tobacco subsidies...) | +====================================================================+