<br><br><div class="gmail_quote">On Mon, Dec 13, 2010 at 11:52 AM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
On 13 December 2010 20:21, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Dec 13, 2010 at 6:14 AM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; | newNil |<br>
&gt;&gt; newNil := UndefinedObject basicNew.<br>
&gt;&gt; nil becomeForward: newNil.<br>
&gt;&gt; (Array new: 1) first == newNil<br>
&gt;&gt;<br>
&gt;&gt; In Cog it just hangs VM (under Mac)<br>
&gt;&gt;<br>
&gt;&gt; Any ideas how to fix that?<br>
&gt;<br>
&gt; I don&#39;t think it&#39;s worth fixing.  It is advantageous for the performance of the VM to be able to embed nil in machine code without needing to mark it as a GCable object, and nil doesn&#39;t really have to change.  Instead you can change the UndefinedObject class via a become.  So for me it&#39;s not worth fixing and in fact I would actively encourage expecting /not/ to be able to redefine nil, true or false.  For example in Cog better code is generated for conditional branches by assuming that true and false are contiguous (in current images 8 bytes apart).  IMO, there are flexibilities that are so unusual they are not worth paying for, and being able to become nil, true and false are in this category.<br>

<br>
<br>
</div></div>I agree its not worth changing.<br>
So, the &#39;fix&#39; is to replace the class, since nil is singleton anyways.<br>
<br>
The problem i that we want to swap special objects array. And there<br>
are two approaches:<br>
<br>
1  - create a full object memory , which is a copy of existing objects<br>
(but not everything, just selected pieces). This means that there will<br>
be two &#39;nils&#39; and therefore need a working #become: for swapping.<br>
<br>
2  - mark a set of objects for inclusion in &#39;new&#39; image, and throw<br>
away the rest via stubbing. So, this approach avoids copying, but also<br>
it doesn&#39;t allows to hold two object memories in object memory at same<br>
time (host and baby one).<br></blockquote><div><br></div><div>Is this for the kernel project?  If so, what are the requirements?  When I looked at MicroSqueak one thing I couldn&#39;t come up with a good answer for was how to deal with nil, true and false while simulating MicroSqueak code in the image.  One could e.g. modify the compiler to generate references to the MicroSqueak nil, true and false but then conditional branch opcodes can&#39;t be used, so one would e.g. have to simulate the bytecode.  That shouldn&#39;t be too much of a problem because there shouldn&#39;t be that much code to execute.  But if e.g. method wrappers could be used that would be nicer.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I advocating for a second approach. It is more simpler as to me, but<br>
at same time, it is only one way road. While with first one,<br>
potentially you could switch between two object memories at will ,<br>
which opening interesting possibilities.<br>
<br>
Btw, are there any other objects which can&#39;t freely use #become: due<br>
to some Cog intrinsics?<br></blockquote><div><br></div><div>nil, true, false are it AFAIA.  However one can&#39;t change the characterTable.  One can become it, or replace its contents, but one can&#39;t assign a new array to the specialObjectsArray and expect it to continue working.</div>
<div><br></div><div>HTH</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
<br>
&gt; best<br>
&gt; Eliot<br>
<br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
</div></div></blockquote></div><br>