[Vm-dev] Re: Reproducible way to crash Cog ( [Lsehub-staff] Strange behavior )

Henrik Johansen henrik.s.johansen at veloxit.no
Thu Dec 9 11:10:59 UTC 2010

On Dec 8, 2010, at 11:42 00PM, Eliot Miranda wrote:

> On Wed, Dec 8, 2010 at 2:14 PM, Andreas Raab <andreas.raab at gmx.de> wrote:
> On 12/8/2010 1:58 PM, Igor Stasenko wrote:
> I never used this prim before, so i didn't knew that it takes the
> class of argument,
> instead an argument itself as a class to which replace receiver's class.
> VisualWorks also started off with a changeClassToThatOf: primitive which took an instance.  We fixed that by providing behavior>adoptInstance:. This still has to extract format info form the receiver (a class) but at least the primitive can assume the receiver is a valid behavior and it only has to check if the argument is suitable as an instance of the class. 
> I wrote this for Cog also, see primitiveAdoptInstance, #160, so if you find this more convenient you can use it; find attached.
> Eliot

Weee, I've missed the adoptInstance: method! 
While I agree it's nothing to use regularly, it can be fun to play around with.
F.ex, I used the primitive some time ago in an evil/clever experiment  to remove depth instVar / methods which branch on depth from Form.

So, to have a method which works on both Cog and non-Cog, could we write:

Behavior >> #adoptInstance: anInstance
<primitive: 160 error: ec>
^anInstance changeClassToThatOf: self basicNew

Or are the failure cases different?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20101209/892e8e7b/attachment-0001.htm

More information about the Vm-dev mailing list