<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi All,<div><br></div><div>    I find myself using something like this to copy methods across hierarchies:</div><div><br></div><div><div>[:s| | class |</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>self halt.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>class := CogVMSimulator whichClassIncludesSelector: s.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>StackInterpreterSimulator recompile: s from: class.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>StackInterpreterSimulator organization classify: s under: (class whichCategoryIncludesSelector: s)] value: #printStringOf:on:.</div><div><br></div><div>because if one simply does recompile:from: and the selector doesn't exist in the target then one ends up with a hidden selector; it's in the method dictionary but because it isn't in the organization it doesn't show in the browser or in Monticello etc.</div><div><br></div><div>The rationale for not having recompile:from: check the organization is a good one; when recompiling a class that has changed shape (had inst vars added or removed) we don't want to waste cycles checking something redundant. So how about having ClassDescription>>recompile:from: doing the check if the receiver doesn't equal the argument class, e.g.:</div><div><br></div><div><div>ClassDescription>>recompile: selector from: oldClass</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>"Preserve the originalTraitMethod (if any) after recompiling a selector"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>| oldMethod |</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>oldMethod := oldClass compiledMethodAt: selector.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>super recompile: selector from: oldClass.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>oldMethod originalTraitMethod ifNotNil:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>[:traitMethod|</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">         </span>(self compiledMethodAt: selector) originalTraitMethod: traitMethod].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>(self ~~ oldClass</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span> and: [(organization numberOfCategoryOfElement: selector) = 0]) ifTrue:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>[organization classify: selector under: (oldClass whichCategoryIncludesSelector: oldClass)]</div></div><div><br></div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div></div></div></div>