<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 3/24/23 8:31 AM, Alexandre Rousseau
via Cuis-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAKmOayLAPDAqsubDRizoXhz_HZ=U3JmX=KV2y38D_FvAt8oiLA@mail.gmail.com">
<pre class="moz-quote-pre" wrap="">I'm trying to modify rather than subclass BoxedMorp, adding a new instance
var to the class definition. This fails while Transcript reports what
follows.
I'm guessing that recompilation of BoxedMorph does not play well while a
WorldMorph (a subclass of BoxedMorph itself) instance is running.
What would be a way to work around this?
Class reshaping: InnerTextMorph has some instance running #acceptContents.
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">This CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: InnerTextMorph has some instance running
#processKeystrokeEvent:. This CompiledMethod would become invalid. Class
reshaping aborted.
Class reshaping: InnerTextMorph has some instance running
#processKeystrokeEvent:. This CompiledMethod would become invalid. Class
reshaping aborted.
Class reshaping: InnerTextMorph has some instance running #keyStroke:.
This CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: InnerTextMorph has some instance running #keyStroke:.
This CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: HandMorph has some instance running
#startKeyboardDispatch:. This CompiledMethod would become invalid. Class
reshaping aborted.
Class reshaping: HandMorph has some instance running #processEventQueue.
This CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: WorldMorph has some instance running #doOneCycleNow. This
CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: WorldMorph has some instance running #handsDo:. This
CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: WorldMorph has some instance running #doOneCycleNow. This
CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: WorldMorph has some instance running #doOneCycle:. This
CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: WorldMorph has some instance running #mainLoop. This
CompiledMethod would become invalid. Class reshaping aborted.
Class reshaping: WorldMorph has some instance running #mainLoop. This
CompiledMethod would become invalid. Class reshaping aborted.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
</blockquote>
First, let me analyze that problem.<br>
Nearly every Morph you see on the screen – <tt>SystemWindow</tt>
and <br>
thus <tt>BrowserWindow</tt> – is derived from <tt>BoxedMorph</tt>.
Juan added save guards<br>
to Object>>#become:, because adding the target object of <tt>#become:</tt><br>
might still have some active contexts on the stack and these<br>
active contexts refer to methods that where compiled for the<br>
source object of <tt>#bceome:</tt>. In your case the source object<br>
is the old class and the target object is the new class, with<br>
the added instance variable. If you will add the instance variable<br>
add the end, it would work out. Otherwise some<br>
morphic code in the running system will certainly crash.<br>
<br>
Now for ways around this mess:<br>
<br>
Do you really need an instance variable?<br>
Morphs also have properties, that should<br>
be used if the instance variable is <tt>nil</tt> for<br>
most morphs. Properties come in handy here,<br>
because the can be added at run-time.<br>
<br>
If you insist on adding instance variables,<br>
you have to add your variable with<br>
no morphic code on the stack, meaning you have to <br>
do it from the command line.<br>
There is a method <tt>Class>>#addInstVarName:</tt> that lets<br>
you add instance variables.<br>
<br>
You can use the <tt>-e</tt> command-line option<br>
to execute code from the command line.<br>
<br>
<br>
HTH,<br>
<br>
Gerald<br>
</body>
</html>