<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi Nicolas,</p>
    <p>Oh gosh! #objectForDataStream: I didn't see that coming! I only
      saw #readInteger and #writeInteger: in Squeak and assumed Squeak
      was broken. And didn't try it before opening my mouth. Apologies
      for my ill informed and rude comment.</p>
    <p>It was only Cuis that was broken until last week WRT this.</p>
    <p>WRT compatibility between Squeak and Cuis wrt DataStream, a lot
      of content is compatible. Larger SmallIntegers written in Squeak
      (as LargeIntegers) will be read correctly in Cuis. But those
      written in Cuis will use a new TypeMap entry with code 25 that
      uses two 32 bit words. I prefer this approach, because I want to
      be able to load DataStreams that don't have any LargeIntegers into
      small bootstrapped images that don't include LargeIntegers at all.
      The 'minimal kernel' images I'm building haven't seen need for
      LargeIntegers yet, and so I prefer not to include them, and keep
      them in a separate pre-compiled "dynamic cuis library". The "25"
      format is easy to add to Squeak, at least for reading, though.</p>
    <p>But I'm pretty sure there are incompatibilities in Character,
      UnicodeString and UnicodeSymbol. Floats and Byte-Strings seem to
      be OK.</p>
    <p>If you want to collaborate with me on keeping DataStream as
      compatible as possible (Morphs are out of the question, I guess!),
      and are willing to make minor tweaks for Squeak, I'm willing to
      make them for Cuis as needed.</p>
    <p>Thanks!</p>
    <div class="moz-cite-prefix">On 23/09/2025 6:11 PM, Nicolas Cellier
      via Cuis-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAKnRiT6evOY_iLpNcHEZjwGJb9H9JXWRZ3bKp=GgZoy=-t1j+g@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>
                <div>Hi Juan,<br>
                </div>
                I fail to see the bug in current Squeak trunk.<br>
              </div>
              I tried this<br>
              <br>
                  | int out file |<br>
                  int := SmallInteger maxVal.<font color="#000000"><br>
                    </font><font color="#6B6B6B">file</font><font
                color="#000000"> </font><b>:=</b><font color="#000000">
              </font><font color="#000000">FileStream</font><font
                color="#000000"> </font><font color="#000080">fileNamed:</font><font
                color="#000000"> </font><font color="#800080">'Test-Int'</font><font
                color="#000000">.</font><font color="#000000"><br>
                    </font><font color="#6B6B6B">file</font><font
                color="#000000"> </font><font color="#000080">binary</font><font
                color="#000000">.</font><font color="#000000"><br>
                    </font><font color="#000000">(</font><font
                color="#000000">DataStream</font><font color="#000000">
              </font><font color="#000080">on:</font><font
                color="#000000"> </font><font color="#6B6B6B">file</font><font
                color="#000000">)</font><font color="#000000"> </font><font
                color="#000080">nextPut:</font><font color="#000000"> </font><font
                color="#000080">int</font><font color="#000000">.</font><font
                color="#000000"><br>
                    </font><font color="#6B6B6B">file</font><font
                color="#000000"> </font><font color="#000080">close</font><font
                color="#000000">.</font><font color="#000000"><br>
                <br>
                    </font><font color="#6B6B6B">file</font><font
                color="#000000"> </font><b>:=</b><font color="#000000">
              </font><font color="#000000">FileStream</font><font
                color="#000000"> </font><font color="#000080">fileNamed:</font><font
                color="#000000"> </font><font color="#800080">'Test-Int'</font><font
                color="#000000">.</font><font color="#000000"><br>
                    </font><font color="#6B6B6B">file</font><font
                color="#000000"> </font><font color="#000080">binary</font><font
                color="#000000">.</font><font color="#000000"><br>
                    </font><font color="#6B6B6B">out</font><font
                color="#000000"> </font><b>:=</b><font color="#000000">
              </font><font color="#000000">(</font><font color="#000000">DataStream</font><font
                color="#000000"> </font><font color="#000080">on:</font><font
                color="#000000"> </font><font color="#6B6B6B">file</font><font
                color="#000000">)</font><font color="#000000"> </font><font
                color="#000080">next</font><font color="#000000">.</font><font
                color="#000000"><br>
                    </font><font color="#6B6B6B">file</font><font
                color="#000000"> </font><font color="#000080">close</font><font
                color="#000000">.</font><font color="#000000"><br>
                <br>
                    self assert: int = out<br>
                <br>
              </font></div>
            <font color="#000000">The large SmallInteger is restored
              correctly.<br>
            </font></div>
          <font color="#000000">This is because we find this method
            timestamped from 2015:<br>
            <br>
          </font><b>SmallInteger>>objectForDataStream:</b><font
            color="#000000"> </font><font color="#000080">refStrm</font><font
            color="#000000"><br>
                </font><font color="#008080"><i>"In a 64-bit Spur VM, we
              may have to fake 32-bit SmallIntegers for compatibility."</i></font><font
            color="#000000"><br>
            <br>
                </font><font color="#808080">|</font><font
            color="#000000"> </font><font color="#6B6B6B">large</font><font
            color="#000000"> </font><font color="#808080">|</font><font
            color="#000000"><br>
                </font><font color="#800000">self</font><font
            color="#000000"> </font><font color="#000080">></font><font
            color="#000000"> </font><font color="#800000">16r3FFFFFFF</font><font
            color="#000000"> </font><font color="#000080">ifTrue:</font><font
            color="#000000"> </font><font color="#000000">[</font><font
            color="#000000"><br>
                    </font><font color="#6B6B6B">large</font><font
            color="#000000"> </font><b>:=</b><font color="#000000"> </font><font
            color="#000000">LargePositiveInteger</font><font
            color="#000000"> </font><font color="#000080">new:</font><font
            color="#000000"> </font><font color="#800000">self</font><font
            color="#000000"> </font><font color="#000080">digitLength</font><font
            color="#000000"> </font><font color="#000080">neg:</font><font
            color="#000000"> </font><font color="#800000">false</font><font
            color="#000000">.</font><font color="#000000"><br>
                    </font><font color="#800000">1</font><font
            color="#000000"> </font><font color="#000080">to:</font><font
            color="#000000"> </font><font color="#800000">self</font><font
            color="#000000"> </font><font color="#000080">digitLength</font><font
            color="#000000"> </font><font color="#000080">do:</font><font
            color="#000000"> </font><font color="#008000">[</font><font
            color="#000000">:</font><font color="#000080">i</font><font
            color="#000000"> </font><font color="#808080">|</font><font
            color="#000000"> </font><font color="#6B6B6B">large</font><font
            color="#000000"> </font><font color="#000080">digitAt:</font><font
            color="#000000"> </font><font color="#000080">i</font><font
            color="#000000"> </font><font color="#000080">put:</font><font
            color="#000000"> </font><font color="#800080">(</font><font
            color="#800000">self</font><font color="#000000"> </font><font
            color="#000080">digitAt:</font><font color="#000000"> </font><font
            color="#000080">i</font><font color="#800080">)</font><font
            color="#008000">]</font><font color="#000000">.</font><font
            color="#000000"><br>
                    </font><font color="#800000">^</font><font
            color="#6B6B6B">large</font><font color="#000000">]</font><font
            color="#000000">.</font><font color="#000000"><br>
                </font><font color="#800000">self</font><font
            color="#000000"> </font><font color="#000080"><</font><font
            color="#000000"> </font><font color="#800000">-</font><font
            color="#800000">16r40000000</font><font color="#000000"> </font><font
            color="#000080">ifTrue:</font><font color="#000000"> </font><font
            color="#000000">[</font><font color="#000000"><br>
                    </font><font color="#6B6B6B">large</font><font
            color="#000000"> </font><b>:=</b><font color="#000000"> </font><font
            color="#000000">LargeNegativeInteger</font><font
            color="#000000"> </font><font color="#000080">new:</font><font
            color="#000000"> </font><font color="#800000">self</font><font
            color="#000000"> </font><font color="#000080">digitLength</font><font
            color="#000000"> </font><font color="#000080">neg:</font><font
            color="#000000"> </font><font color="#800000">true</font><font
            color="#000000">.</font><font color="#000000"><br>
                    </font><font color="#800000">1</font><font
            color="#000000"> </font><font color="#000080">to:</font><font
            color="#000000"> </font><font color="#800000">self</font><font
            color="#000000"> </font><font color="#000080">digitLength</font><font
            color="#000000"> </font><font color="#000080">do:</font><font
            color="#000000"> </font><font color="#008000">[</font><font
            color="#000000">:</font><font color="#000080">i</font><font
            color="#000000"> </font><font color="#808080">|</font><font
            color="#000000"> </font><font color="#6B6B6B">large</font><font
            color="#000000"> </font><font color="#000080">digitAt:</font><font
            color="#000000"> </font><font color="#000080">i</font><font
            color="#000000"> </font><font color="#000080">put:</font><font
            color="#000000"> </font><font color="#800080">(</font><font
            color="#800000">self</font><font color="#000000"> </font><font
            color="#000080">digitAt:</font><font color="#000000"> </font><font
            color="#000080">i</font><font color="#800080">)</font><font
            color="#008000">]</font><font color="#000000">.</font><font
            color="#000000"><br>
                    </font><font color="#800000">^</font><font
            color="#6B6B6B">large</font><font color="#000000">]</font><font
            color="#000000">.</font><font color="#000000"><br>
                </font><font color="#800000">^</font><font
            color="#000000"> </font><font color="#800000">self</font>
          <div><font color="#000000"><br>
            </font></div>
          <div><font color="#000000">Did I overlook something?</font></div>
          <font color="#000000">I hope that Cuis and Squeak DataStream
            will remain consistent after your latest changes<br>
            <br>
          </font></div>
        <font color="#000000">Nicolas</font></div>
      <br>
      <div class="gmail_quote gmail_quote_container">
        <div dir="ltr" class="gmail_attr">Le lun. 22 sept. 2025 à 15:45,
          Juan Vuletich via Cuis-dev <<a
            href="mailto:cuis-dev@lists.cuis.st" moz-do-not-send="true"
            class="moz-txt-link-freetext">cuis-dev@lists.cuis.st</a>>
          a écrit :<br>
        </div>
        <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <p>Hi,</p>
            <div>On 22/09/2025 10:10 AM, H. Hirzel via Cuis-dev wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                <div>I could identify the change set which causes the
                  problem, it is from last Wednesday<br>
                </div>
                <div><br>
                </div>
                <div>CoreUpdates\<a
href="http://7580-ReferenceStream-61BitSmallIntegers-fix-JuanVuletich-2025Sep17-08h16m-jmv.001.cs.st"
                    target="_blank" moz-do-not-send="true">7580-ReferenceStream-61BitSmallIntegers-fix-JuanVuletich-2025Sep17-08h16m-jmv.001.cs.st</a></div>
                <div><br>
                </div>
                <div>It introduces a new version of #readInteger and
                  writeInteger: in the class DataStream.</div>
                <div>If I undo the change of this change set it works.</div>
                <div><br>
                </div>
                <div>--Hannes<br>
                </div>
              </div>
            </blockquote>
            <p><br>
            </p>
            <p>As you saw in that changeset (file name, comments in
              code, commit message), and as exemplified in the test
              added to BaseImageTests shortly after, what that code does
              is not to cause a problem, but to fix a serious bug that
              has been around for a long time and that is still present
              in Squeak. Just try to serialize an object with a largish
              SmallInteger and see what you get back.</p>
            <p>Anyway. I just pushed a better implementation that uses a
              different format for 32bit SmallIntegers than from larger
              ones. This brings back compatibility with the badly broken
              Squeak format, although it obviously can't bring back the
              bits that Squeak discarded when saving the file, and
              results will be wrong unless you're lucky enough to only
              use small SmallIntegers.</p>
            <p><br>
            </p>
            <blockquote type="cite">
              <div dir="ltr">
                <div><br>
                </div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div><br>
                </div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Mon, Sep 22, 2025
                  at 2:36 PM H. Hirzel <<a
                    href="mailto:hannes.hirzel@gmail.com"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">hannes.hirzel@gmail.com</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div dir="ltr">
                    <div>I am currently identifying which change set
                      causes the problem.</div>
                    <div>So far Cuis update 7523 still works.<br>
                    </div>
                    <div><br>
                    </div>
                    <div>This means if I produce a file '
                      aDictWithByteArraysFromSq.obj' in Squeak I can
                      read it in Cuis 7523</div>
                    <div><br>
                    </div>
                    <div>So the problem has been introduced in one of
                      the last 60 updates.</div>
                    <div><br>
                    </div>
                    <div><br>
                    </div>
                    <div class="gmail_quote">
                      <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                        <div dir="ltr">
                          <div>"Squeak"<br>
                            dict := Dictionary new.<br>
                            dict at: 1 put: #[1 2 3 4].<br>
                            dict at: 2 put: #[5 6 7 8].<br>
                            dict at: 3 put: #[10 20 30 40].<br>
                            <br>
                            fileStream := ReferenceStream fileNamed:
                            'aDictWithByteArraysFromSq.obj'.<br>
                            objectToSave := dict.<br>
                            fileStream nextPut: objectToSave.<br>
                            fileStream close</div>
                          <div><br>
                          </div>
                        </div>
                      </blockquote>
                      <div> </div>
                      <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                        <div dir="ltr">
                          <div>"-----------------------------------------------"<br>
                          </div>
                          <div>"Restore in Cuis"<br>
                          </div>
                          <div>ReferenceStream restoreFromFile:
                            ('aDictWithByteArraysFromSq.obj'
                            asFileEntry).<br>
                            <br>
                            "Result<br>
                            OK in Cuis 7523<br>
                            NOT OK in Cuis 7584"</div>
                          <div><br>
                          </div>
                        </div>
                      </blockquote>
                    </div>
                  </div>
                </blockquote>
              </div>
              <br>
              <fieldset></fieldset>
            </blockquote>
            <pre cols="72">-- 
Juan Vuletich
<a href="http://www.cuis.st" target="_blank" moz-do-not-send="true">www.cuis.st</a>
<a href="http://github.com/jvuletich" target="_blank"
            moz-do-not-send="true">github.com/jvuletich</a>
<a href="http://researchgate.net/profile/Juan-Vuletich" target="_blank"
            moz-do-not-send="true">researchgate.net/profile/Juan-Vuletich</a>
<a href="http://independent.academia.edu/JuanVuletich" target="_blank"
            moz-do-not-send="true">independent.academia.edu/JuanVuletich</a>
<a href="http://patents.justia.com/inventor/juan-manuel-vuletich"
            target="_blank" moz-do-not-send="true">patents.justia.com/inventor/juan-manuel-vuletich</a></pre>
          </div>
          -- <br>
          Cuis-dev mailing list<br>
          <a href="mailto:Cuis-dev@lists.cuis.st" target="_blank"
            moz-do-not-send="true" class="moz-txt-link-freetext">Cuis-dev@lists.cuis.st</a><br>
          <a href="https://lists.cuis.st/mailman/listinfo/cuis-dev"
            rel="noreferrer" target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis.st">www.cuis.st</a>
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich</pre>
  </body>
</html>