<div dir="auto">Juan, the vm has support for immutability for quite some time, so it might be time to use it for literals.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 17 juil. 2024, 19:01, Juan Vuletich via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>

  
    
  
  <div bgcolor="#ffffff" text="#000000">
    On 7/17/2024 12:43 PM, Mark Volkmann via Cuis-dev wrote:
    <blockquote type="cite">
      <div dir="ltr">Interesting! In this code I create two equivalent
        String objects, then modify a character in one of them. I
        wondered if it would do a "copy on write", but it did not. The
        modification affected both which was surprising to me.
        <div><br>
        </div>
        <div>str1 := 'test'.<br>
          str2 := 'test'.<br>
          str1 at: 1 put: $b.<br>
          <br>
        </div>
        <div>In this case, str1 and str2 refer to the same object in
          memory, so both now have the value "best".</div>
        <div><br>
        </div>
        <div>I suppose the lesson is that literal strings in the same
          scope might (always?) use the same object in memory.</div>
      </div>
    </blockquote>
    <br>
    The other lesson, at least to me, is that String mutation is bad
    (and ugly). It is generally better to create them anew, in a more
    functional style.<br>
    <br>
    <blockquote type="cite"><br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Jul 17, 2024 at
          10:12 AM Juan Vuletich <<a href="mailto:juan@cuis.st" target="_blank" rel="noreferrer">juan@cuis.st</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 bgcolor="#ffffff"> On 7/17/2024 11:08 AM, Mark Volkmann
            via Cuis-dev wrote:
            <blockquote type="cite">
              <div dir="ltr">
                <div dir="ltr">When I enter the following lines in a
                  Workspace, select them, and "Do it", I get an
                  AssertionFailure error:
                  <div><br>
                  </div>
                  <div><font face="monospace">str1 := 'test'.<br>
                      str2 := 'test'.<br>
                      self assert: str1 ~~ str2.</font><br>
                  </div>
                  <div><br>
                  </div>
                  <div>Ken, are you saying that you do not get that
                    error?</div>
                </div>
                <div><br>
                </div>
                <span class="gmail_signature_prefix">-- </span><br>
                <div dir="ltr" class="gmail_signature">
                  <div dir="ltr">
                    <div>
                      <div dir="ltr">
                        <div>
                          <div dir="ltr">
                            <div dir="ltr">
                              <div><font face="arial, helvetica,
                                  sans-serif">R. Mark Volkmann</font></div>
                              <div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object

                                    Computing, Inc.</font></span></div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </blockquote>
            <br>
            Side comment: an AssertionFailure is an Exception but not an
            Error (see class hierarchy).<br>
            <br>
            You get the AssertionFailure if you select all three lines
            and evaluate them together, but not if you evaluate them one
            by one.<br>
            <br>
            Truth is that str1 and str2 can not be assumed to be the
            same object. But they can not be assumed to be different
            object either. The compiler is free to reuse the string if
            it is easy enough.<br>
            <br>
            Cheers,<br>
            <pre cols="72">-- 
Juan Vuletich
<a href="http://cuis.st" target="_blank" rel="noreferrer">cuis.st</a>
<a href="http://github.com/jvuletich" target="_blank" rel="noreferrer">github.com/jvuletich</a>
<a href="http://researchgate.net/profile/Juan-Vuletich" target="_blank" rel="noreferrer">researchgate.net/profile/Juan-Vuletich</a>
<a href="http://independent.academia.edu/JuanVuletich" target="_blank" rel="noreferrer">independent.academia.edu/JuanVuletich</a>
<a href="http://patents.justia.com/inventor/juan-manuel-vuletich" target="_blank" rel="noreferrer">patents.justia.com/inventor/juan-manuel-vuletich</a>
<a href="http://linkedin.com/in/juan-vuletich-75611b3" target="_blank" rel="noreferrer">linkedin.com/in/juan-vuletich-75611b3</a>
<a href="http://twitter.com/JuanVuletich" target="_blank" rel="noreferrer">twitter.com/JuanVuletich</a></pre>
          </div>
        </blockquote>
      </div>
      <br clear="all">
      <div><br>
      </div>
      <span class="gmail_signature_prefix">-- </span><br>
      <div dir="ltr" class="gmail_signature">
        <div dir="ltr">
          <div>
            <div dir="ltr">
              <div>
                <div dir="ltr">
                  <div dir="ltr">
                    <div><font face="arial, helvetica, sans-serif">R.
                        Mark Volkmann</font></div>
                    <div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object
                          Computing, Inc.</font></span></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    <br>
    <pre cols="72">-- 
Juan Vuletich
<a href="http://cuis.st" target="_blank" rel="noreferrer">cuis.st</a>
<a href="http://github.com/jvuletich" target="_blank" rel="noreferrer">github.com/jvuletich</a>
<a href="http://researchgate.net/profile/Juan-Vuletich" target="_blank" rel="noreferrer">researchgate.net/profile/Juan-Vuletich</a>
<a href="http://independent.academia.edu/JuanVuletich" target="_blank" rel="noreferrer">independent.academia.edu/JuanVuletich</a>
<a href="http://patents.justia.com/inventor/juan-manuel-vuletich" target="_blank" rel="noreferrer">patents.justia.com/inventor/juan-manuel-vuletich</a>
<a href="http://linkedin.com/in/juan-vuletich-75611b3" target="_blank" rel="noreferrer">linkedin.com/in/juan-vuletich-75611b3</a>
<a href="http://twitter.com/JuanVuletich" target="_blank" rel="noreferrer">twitter.com/JuanVuletich</a></pre>
  </div>

-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank" rel="noreferrer">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div>