<br><br><div class="gmail_quote">On Fri, Sep 21, 2012 at 1:13 PM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I guess we&#39;re going off the track with class renaming. The problem I&#39;d like to solve is:<br>
If we remove a class and then add a class to the system with the same name, then the methods which were referring to the class before the removal are still referring to the same old class. This means that two bindings will coexist in the system with the same class name, but pointing to different classes.<br>
</blockquote><div><br></div><div>Let me get this clear.  Surely the methods should still refer to the class named X after removing and adding back a class named X right?  That can (and should) be accomplished by moving the binding to Undeclared on removing it and usiong the binding when declaring the filed-in class.  This is the way the system used to work and should continue to work.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
How is class renaming related to this?<br>
One of the possible solutions is to move the removed class&#39;s binding to Undeclared. When you rename a class, then Class &gt;&gt; #rename: will check if there&#39;s a binding with the new class name in Undeclared. The problem here is that Undeclared doesn&#39;t release bindings automatically (when they are not referenced by any methods anymore), so bindings gone long ago are still lingering in Undeclared, therefore Class &gt;&gt; #rename: (and also Trait <br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
#rename:) will #inform: the user about it, which breaks one of the <br>
</blockquote></blockquote>
tests.<br></blockquote><div><br></div><div>But that&#39;s not a problem.  The set-up for these tests can (and should) prune unreferenced bindings from Undeclared, either before running or before complaining of there being bindings in Undeclared.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">But there&#39;s another problem with this solution:<br>
There&#39;s a test which tests if a removed class&#39;s method is still referencing to the class. So replacing the value of the binding with nil is not possible.<br></blockquote><div><br></div><div>But that&#39;s a bogus test.  Of course the binding&#39;s value should be set to nil.  Either the class has been removed or renamed.  The only thing that makes sense with remove is to set it to nil.  Rename is more difficult.  It makes sense to leave it pointing to the new class if the system is running interactively while the user edits methods to refer to the class under the new name. Tricky.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If we don&#39;t replace the value with nil, then the binding isn&#39;t really undeclared. So there will be bindings in Undeclared with non-nil value, which might have side effects in the system.<br>
<br>
How does the solution I suggested work:<br>
- when a class is removed, then its binding will be thrown away<br>
- all methods referring to the class are recompiled. This means that if any such method exists, then a new binding will be created in Undeclared and all methods will use that new binding.<br>
The drawback is that mass class removal will be slower. Removing a single class will have no noticable difference for the user (20-40ms+the recompilation time).<br></blockquote><div><br></div><div>I don&#39;t see that this is usefully different from the existing behaviour.  There seem to me to be two cases, one is renaming a class that is key to the system functioning, say some class in the compiler.  If the binding is set to nil then the system will break on trying to compile edited versions of the methods that refer to the class.  That&#39;s tough, but one has to accept it.  The work-around is to clone the class under the new name (e.g. file-out, edit, file back in) and move all subclasses under the new class, and then remove the old class.  The other case is where the class isn&#39;t key and the system keeps running.  In either case, keeping the exsting binding and setting its value to nil is the correct behaviour; it maintains system integrity w.r.t. bindings.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
For completeness, here&#39;s a list of problems I don&#39;t want to solve now:<br>
- Undeclared holding onto bindings forever<br></blockquote><div><br></div><div>non-problem.  tests that test Undeclared must prune unreferenced bindings from Undeclared.  The cost is small.  F**ing up Undeclared to make the tests run fast is a case of the tail wagging the dog.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- Undeclared introducing Associations for classes instead of ReadOnlyVariableBindings<br></blockquote><div><br></div><div>Again if the binding is preserved this won&#39;t happen.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

- how class renaming works</blockquote><div><br></div><div>has it changed?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
<br>
On Fri, 21 Sep 2012, Eliot Miranda wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I don&#39;t understand.  How else can one use Undeclared?  Any binding in a method which is undefined should be in Undefined.  Hence when a class is removed or when a class is renamed the binding should be moved to Undeclared and left<br>

</blockquote>
<br></div>
Some code uses #at:put: only, others try #includesKey: and #at:ifAbsent: which might not work as expected (see above).<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
there, but when a class is renamed we can offer the user the opportunity to redefine methods that refer to the class with the old name (edit the methods to change the name to the new name).<br>
</blockquote>
<br></div>
Should a removed class&#39;s binding - which is still pointing to the class - be in Undeclared? Will it cause any issues that the binding is still pointing to the class?<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
Levente</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
One might think that on rename the binding can be reused and its key changed.  But this would leave the methods referring to the new class but with their source naming the old name, hence on recompile the methods would now refer to<br>

the binding ... in Undeclared.  So the only correct thing for me is to move the binding to Undeclared, and, if interactive, offer up either a list browser of all references to the class, or an option to edit those methods<br>

automatically.<br>
<br>
<br>
      The only reason I know about Class &gt;&gt; #rename: is because a test was failing when I moved the binding to Undeclared. It might not be that hard to find the methods, but it&#39;s still extra work to be done. I&#39;ll check it out<br>

      though, because class renaming is definitely more rare than class removal.<br>
<br>
<br>
      Levente<br>
<br>
<br>
<br>
<br>
<br>
--<br>
best,Eliot<br>
<br>
<br>
</blockquote>
</div></div><br><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>