[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]
Collection During Construction
- To: <eric>
- Subject: Collection During Construction
- From: Mark S. Miller <mark>
- Date: Fri, 13 Jul 90 18:19:10 PDT
- Cc: <xtech>, <michael>
- In-reply-to: <eric@son-of-blob'smessageofFri>,05 PDT <9007132340.AA26461@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Jul 90 14:25:55 PDT
From: eric@son-of-blob
... not garbage collector safe, since the result of the constructor is
not a strong pointer. Therefore, people should avoid and xlint++ should
catch the following
[any function/pseudoconstructor] ( ... new Class (...) ... )
equivalently in smalltalk you should never do
foo msg: Class create
Date: Fri, 13 Jul 90 16:40:05 PDT
From: eric@son-of-blob
Another one for xlint to catch:
DerivedClass::DerivedClass (ArgType * arg)
: BaseClass (::function(arg)) {
...
}
If function(arg) allocates any storage, the object under construction may
vanish during garbage collection. ...
The arguments for BaseClass may only be trivial, such as constants or
unprocessed pointers.
Ouch. Talking about this, with Mr. Hill & I realized that the new
CONSTRUCTOR_BOMB proposal would also solve both of the above problems.
We would have the generic constructor bomb for Heapers have a CHARGE
type of "SPTR(Heaper)" instead of "Heaper *" (alternatively, since
SPTRs are themselves a special kind of Bomb, we could combine these
somehow for efficiency. A clean combination doesn't occur to me at
the moment).
The big moose remains: How do we write "new"/"create" expressions in
Smalltalk so that they translate to the new CONSTRUCTOR_BOMB style,
what do we need to do in the translator, and how do we get it to mean
the same thing in Smalltalk (wrt destructor invocation)?
Until this moose is solved, Mr. Hill's two solutions above seem quite
painless (given xlint support).