gintera@fsd.cpsc.ucalgary.ca (Andrew Ginter) (02/06/91)
Archive-name: languages/c++/coop-garbage-collector/1991-02-05 Archive: ucnet.ucalgary.ca:DUA3:[ANONYMOUS.PUB.TECH]CPSC-91-417-01-DVI.Z [136.159.1.21] Original-posting-by: gintera@fsd.cpsc.ucalgary.ca (Andrew Ginter) Original-subject: Re: Smart Pointers - Another Proposal Reposted-by: emv@ox.com (Edward Vielmetti) I agree with Tim Atkins' assessment of dumb pointer temporary problems in Ron Guilmette's most recent smart pointers proposal (the one that overloads operator& and operator T&). These problems can be overcome in single-tasking, serially garbage collected applications if the compiler understands that for expressions involving smart pointers: * all side effects of evaluating a component of an expression must take effect before evaluating the next component, and * the RHS of primitive assignment operators (including +=, ++, etc.) must be evaluated before the LHS is evaluated. These restrictions rule out some optimizations, but they work. These are not the only restrictions that work, and they are not the weakest that work, though they may be the simplest outside of conservative collectors. Additional compiler support is required to support parallel and incremental collectors and parallel applications. There are other problems with the proposal. For instance: * it is not clear in function signatures whether or not a pointer is smart, and * there is no way to explicitly use a dumb pointer to a smart class, even if a developer knows that such use is safe. I think that the way around these problems is to to identify smart pointers as such to C++ compilers explicitly. This can be done with a new keyword (the Modula-3 "traced" comes to mind) or by some other syntactic convention in the declaration of smart pointer classes. If anyone's interested, I've just finished writing a technical report describing problems with various smart pointer proposals in the context of a cooperative garbage collector for C++. The report is available via anonymous ftp from ucnet.ucalgary.ca, in the file DUA3:[ANONYMOUS.PUB.TECH]CPSC-91-417-01-DVI.Z. The file really is a compress'ed ".dvi" file, even if the naming is a bit off. Andrew Ginter, 403-220-6320, gintera@cpsc.ucalgary.ca