looks good. I'll integrate in Cog soon. BTW, you can use fetchClassOfNonInt: where you know you won't encounter an immediate, hence<br><br><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div>
<span style="white-space: pre-wrap; ">printNameOfClass: classOop count: cnt
        "Details: The count argument is used to avoid a possible infinite recursion if classOop is a corrupted object."
        | metaclassClass |
        cnt <= 0 ifTrue: [ ^ self print: 'bad class' ].
        metaclassClass := self <span class="Apple-style-span" style="border-collapse: separate; font-family: arial; white-space: normal; font-size: small; ">fetchClassOfNonInt</span>: (self <span class="Apple-style-span" style="border-collapse: separate; font-family: arial; white-space: normal; font-size: small; ">fetchClassOfNonInt</span>: (self fetchPointer: ClassInteger ofObject: specialObjectsOop)).
        metaclassClass = (self <span class="Apple-style-span" style="border-collapse: separate; font-family: arial; white-space: normal; font-size: small; ">fetchClassOfNonInt</span>: classOop) "Is it a metaclass?"
                ifTrue: [self printNameOfClass: (self fetchPointer: 5 "thisClass" ofObject: classOop) count: cnt - 1.
                                self print: ' class']
        ifFalse: [self printStringOf: (self fetchPointer: 6 "name" ofObject: classOop)]</span></div><div><span style="white-space: pre-wrap; "><br></span></div></span><div class="gmail_quote">On Thu, Mar 31, 2011 at 8:51 PM, Javier Pimás <span dir="ltr"><<a href="mailto:elpochodelagente@gmail.com">elpochodelagente@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <br>Hi, this method of Interpreter is used for debugging, and should print the name of the class passed in console:<div>
<br></div><div><div>printNameOfClass: classOop count: cnt</div><div><span style="white-space:pre-wrap">        </span>"Details: The count argument is used to avoid a possible infinite recursion if classOop is a corrupted object."</div>
<div><br></div><div><span style="white-space:pre-wrap">        </span>cnt <= 0 ifTrue: [ ^ self print: 'bad class' ].</div><div><span style="white-space:pre-wrap">        </span>(self sizeBitsOf: classOop) = (7 * self bytesPerWord)<span style="white-space:pre-wrap">        </span>"(Metaclass instSize+1 * 4)"</div>
<div><span style="white-space:pre-wrap">                </span>ifTrue: [self printNameOfClass: (self fetchPointer: 5 "thisClass" ofObject: classOop) </div><div><span style="white-space:pre-wrap">                                        </span>count: cnt - 1.</div>
<div><span style="white-space:pre-wrap">                                </span>self print: ' class']</div><div><span style="white-space:pre-wrap">        </span>ifFalse: [self printStringOf: (self fetchPointer: 6 "name" ofObject: classOop)]</div>
<div><br></div><div>it's logic is this: if the classOop is of a normal Class instance, it should use the instance var number six, which corresponds to the class' name. If not, then the classOop represents a Metaclass instance, and then it will fetch inst var number 5, which is the corresponding class, print its name, and then print 'class' to let you distinguish it that it is a metaclass.</div>
<div><br></div><div>The problem of the method is that it determines if it's a class instance or a metaclass instance by looking at the size of the oop, which seems to have changed, at least in pharo (Metaclass instSize+1 * 4 = 36 = 9*bytesPerWord). </div>
<div><br></div><div>The method could be fixed by changing 7 to 9 then. But it will break if Metaclass changes again. So I have this idea: make it check if the classOop is a metaclass instance. Metaclass class is not a special object, but can be obtained by accessing any special one, like with </div>
<div><br></div><div>Integer class class</div><div><br></div><div>or directly with</div><div><br></div><div>nil class class class (!!)</div><div><br></div><div>then the proposed code is:</div><div><br></div><div><span style="white-space:pre-wrap">printNameOfClass: classOop count: cnt
        "Details: The count argument is used to avoid a possible infinite recursion if classOop is a corrupted object."
        | metaclassClass |
        cnt <= 0 ifTrue: [ ^ self print: 'bad class' ].
        metaclassClass := self fetchClassOf: (self fetchClassOf: (self fetchPointer: ClassInteger ofObject: specialObjectsOop)).
        metaclassClass = (self fetchClassOf: classOop) "Is it a metaclass?"
                ifTrue: [self printNameOfClass: (self fetchPointer: 5 "thisClass" ofObject: classOop)
                                        count: cnt - 1.
                                self print: ' class']
        ifFalse: [self printStringOf: (self fetchPointer: 6 "name" ofObject: classOop)]</span></div><div><br></div><div><br></div><div>I'd also like to have this included too:</div><div><br></div><div><div>printClassOf: oop</div>
<div><span style="white-space:pre-wrap">        </span>"Print the class of the oop in console"</div><div><span style="white-space:pre-wrap">        </span>self printNameOfClass: (self fetchClassOf: oop) count: 5. </div>
</div><div><br></div><div>which is simple but pretty much useful.</div><div><br></div><div>What do you think?</div><div><br></div><div>Regards,</div><div> Javier.</div><br>-- <br>Javier Pimás<br>Ciudad de Buenos Aires<br>
</div>
<br></blockquote></div><br></div>