<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 8, 2010, at 11:42 00PM, Eliot Miranda wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On Wed, Dec 8, 2010 at 2:14 PM, Andreas Raab <span dir="ltr">&lt;<a href="mailto:andreas.raab@gmx.de">andreas.raab@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 12/8/2010 1:58 PM, Igor Stasenko wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I never used this prim before, so i didn't knew that it takes the<br>
class of argument,<br>
instead an argument itself as a class to which replace receiver's class.<br></blockquote></div></blockquote><div><br></div><div>VisualWorks also started off with a changeClassToThatOf: primitive which took an instance. &nbsp;We fixed that by providing behavior&gt;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.&nbsp;</div>
<div><br></div><div>I wrote this for Cog also, see&nbsp;primitiveAdoptInstance, #160, so if you find this more convenient you can use it; find attached.</div><div><br></div><div>HTH</div><div>Eliot</div></div></blockquote><br></div><div>Weee, I've missed the adoptInstance: method!&nbsp;</div><div>While I agree it's nothing to use regularly, it can be fun to play around with.</div><div>F.ex, I used the primitive some time ago in an evil/clever experiment &nbsp;to remove depth instVar / methods which branch on depth from Form.</div><div><br></div><div>So, to have a method which works on both Cog and non-Cog, could we write:</div><div><br></div><div>Behavior &gt;&gt; #adoptInstance: anInstance</div><div>&lt;primitive: 160 error: ec&gt;</div><div>^anInstance changeClassToThatOf: self basicNew</div><div><br></div><div>Or are the failure cases different?</div><br><div>Cheers,</div><div>Henry</div></body></html>