Hi Guillermo,<br><br><div class="gmail_quote">On Tue, Apr 17, 2012 at 8:33 AM, Guillermo Polito <span dir="ltr">&lt;<a href="mailto:guillermopolito@gmail.com">guillermopolito@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">
 <br>Hi!<br><br>I&#39;m playing to bootstrap a Pharo image, trying to get a new environment running into my &#39;host&#39; image, and after that, dump those new objects into a new image file.<br><br>Now, to do that, I&#39;m creating new classes for String, Character...  Which are well known by the vm specialObjectsArray.  And trying to initialize my new image classes, which creates new character objects, and new string objects which is causing me some troubles :P.<br>

<br>Now, my question is about this check in vmmaker (and some others that look similar):<br><br>Interpreter&gt;&gt;#asciiOfCharacter: characterObj  &quot;Returns an integer object&quot;<br>    &lt;inline: false&gt;<br>    <b>self assertClassOf: characterObj is: (self splObj: ClassCharacter).</b><br>

    successFlag<br>        ifTrue: [^ self fetchPointer: CharacterValueIndex ofObject: characterObj]<br>        ifFalse: [^ ConstZero]  &quot;in case some code needs an int&quot;<br><br><br>- Can&#39;t we put a more intelligent assersion like checking if the object responds true to #isCharacter?<br>
</blockquote><div><br></div><div>The issue is performance.  One wants as quick a test here as possible, so testing the class of the receiver is faster than doing a probe on the method lookup cache and much faster than possibly having to do a full class lookup.  So realistically the answer is &quot;no, we shouldn&#39;t&quot;.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- And removing the static check from the vm and adding the dynamic and nice #isCharacter check into the image?<br></blockquote><div><br></div><div> This doesn&#39;t make a lot of sense.  asciiOfCharacter: is being used in the VM by various primitives (e.g. at:put: on strings) and its use is to fail if one attempts to store other than a character in a string.  So moving the test to the image means the primitive is not safe.  Keep on moving in this direction and you end up with a system that will crash when one makes an error instead of raising an error message.  Smalltalk is a safe language; it is extremely important that the system not crash and instead provide walkbacks that afford diagnosis of errors.</div>
<div><br></div><div><br></div><div>The real issue here is that you want more flexibility in the VM while bootstrapping than one wants or needs in normal use.  Instead of making the VM slow and more general than it need be the right approach is to create a variant of the VM for your bootstrapping use.  You can do this by creating a subclass of Interpreter which reimplements asciiOfCharacter: (and others you may need) and testing it in the simulator.  You can then use your flexible VM for the bootstrap and once complete use the normal VM.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>Thanks!<br>Guille<br><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>