<br><br><div class="gmail_quote">On Thu, Sep 15, 2011 at 9:45 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com">marianopeck@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;">
Ok, I understand. But <br><br><div class="gmail_quote"><div><div></div><div class="h5">On Thu, Sep 15, 2011 at 6:05 PM, Henrik Sperre Johansen <span dir="ltr">&lt;<a href="mailto:henrik.s.johansen@veloxit.no" target="_blank">henrik.s.johansen@veloxit.no</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div><div></div><div>
    On 15.09.2011 17:27, Mariano Martinez Peck wrote:
    <blockquote type="cite">
      
      Hi guys. I am having a problem with the integration of issue 4538:
      <a href="http://code.google.com/p/pharo/issues/detail?id=4538" target="_blank">http://code.google.com/p/pharo/issues/detail?id=4538</a><br>
      <br>
      I am serializing CompiledMethods with Fuel and then I materialize
      them. To test they are correct, I use #= <br>
      So far it was working correctly, but now for the materialized
      method it says they are not equal. The problem is that #= is
      failing in<br>
      <br>
      (self sameLiteralsAs: aCompiledMethod)<br>
      <br>
      And inside that method, it is failing because     (literal1 ==
      literal2 or: [ literal1 literalEqual: literal2 ])<br>
      answers false.<br>
      <br>
      So... why literal1 literalEqual: literal2 answers false?  from
      what I can say, having that selector: &quot;literalEqual&quot;, then both
      MUST be equal, because they are. <br>
      The problem is that it was added:<br>
      <br>
      Association &gt;&gt; literalEqual: otherLiteral<br>
          &quot;Answer true if the receiver and otherLiteral represent the
      same literal.<br>
          Variable bindings are literally equals only if identical.<br>
          This is how variable sharing works, by preserving identity and
      changing only the value.&quot;<br>
          ^self == otherLiteral<br>
      <br>
      <br>
      So....I am not sure I agree with this change. <br>
      <br>
      Any idea how can we deal with this problem?<br>
      <br>
      Cheers<br>
      <br>
      -- <br>
      Mariano<br>
      <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
      <br>
    </blockquote></div></div>
    The change is correct, here&#39;s an example:<br>
    <br>
    Create a global:<br>
    Global := 1<br>
    <br>
    Create a method:<br>
       foo<br>
        ^Global<br>
    <br>
    Serialize method, deserialize<br>
    <br>
    Change value of global: <br>
    Global := 5.<br>
    <br>
    foo should return 5, not 1. <br>
    Unless it&#39;s actually the same association as in the
    SystemDictionary, this will not be true.<br>
    <br></div></blockquote></div></div><div><br>I understand that. In fact, in Fuel we use exactly the same association of SystemDictionary for globals. Look this test example:<br><br>testGlobalVariableMethod<br><br>    | materializedCompiledMethod |<br>

    Smalltalk globals at: #TestGlobalVariableMethod2 put: false. <br>    (self class compileSilently: &#39;globalVariableForTestingMethod<br>    Transcript name. <br>    ^ GlobalVariableForTesting.&#39;).<br><br>    materializedCompiledMethod := self materializedCompiledMethod: (self class &gt;&gt; #globalVariableForTestingMethod).<br>

    Smalltalk globals at: #GlobalVariableForTesting put: true. <br>    self assert:  (materializedCompiledMethod valueWithReceiver: self arguments: #()).<br><br><br><br>BUT, it doesn&#39;t mean that Association is always used for globals. CompiledMethod equality is failing because of the last literal, the one that maps class name (symbol) and point to the real class. So...when I materialize, both CMs have non-identical associations for the last literal, but equal. <br>
</div></div></blockquote><div><br></div><div>As Henrik says the last literals are ideally #== to each other.  However, no Squeak dialect makes any attempt to keep the class0side associations equal. Look at a class-side method and you&#39;ll see it&#39;s last literal is nil-&gt;SomeClass class.  Now since this association doesn&#39;t exist in Smalltalk (unlike last literals on the instance side) the compiler merely creates distinct ones for each class-side method.</div>
<div><br></div><div>Personally I don&#39;t think one can defend the position where method equality is different for instance-side or class-side methods so there must be some solutions:</div><div><br></div><div>1. special case comparison of the last literal (the methodClass literal), comparing keys and insisting that the keys be #== and the values be #== (can&#39;t just define it as keys #== since all similar class-side methods will be equal irrespective of their actual class).</div>
<div><br></div><div>2. special case comparison of the last literal (the methodClass literal), insisting only that the class of the literal be the same if it isVariableBinding.</div><div><br></div><div>3. make the compile unique class-side methodClass literals.  i.e. if a class already has a class-side method then the compiler or method dictionary insertion code must find that existing association and reuse it</div>
<div><br></div><div>Other ideas?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div>
>From my point of view, that literal, the last one does not need to be identical to assume 2 CMs are equal. They just need to be equal. <br></div></div><div><div></div><div class="h5"><br clear="all"><br>-- <br>Mariano<br>
<a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>