[Cuis-dev] String vs Symbol objects

Juan Vuletich juan at cuis.st
Wed Jul 17 11:17:36 PDT 2024


Yep. We have an Immutability package since 2019. We only removed support 
for V3 images earlier this year, so we are on our way of taking full 
advantage of Spur. So far we've added immediate Characters (Unicode 
Range), 16bit and 64bit slot numeric Arrays, and most likely other stuff 
I don't remember right now.

Thanks,

On 7/17/2024 1:05 PM, Nicolas Cellier via Cuis-dev wrote:
> Juan, the vm has support for immutability for quite some time, so it 
> might be time to use it for literals.
>
> Le mer. 17 juil. 2024, 19:01, Juan Vuletich via Cuis-dev 
> <cuis-dev at lists.cuis.st <mailto:cuis-dev at lists.cuis.st>> a écrit :
>
>     On 7/17/2024 12:43 PM, Mark Volkmann via Cuis-dev wrote:
>>     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.
>>
>>     str1 := 'test'.
>>     str2 := 'test'.
>>     str1 at: 1 put: $b.
>>
>>     In this case, str1 and str2 refer to the same object in memory,
>>     so both now have the value "best".
>>
>>     I suppose the lesson is that literal strings in the same scope
>>     might (always?) use the same object in memory.
>
>     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.
>
>>
>>     On Wed, Jul 17, 2024 at 10:12 AM Juan Vuletich <juan at cuis.st
>>     <mailto:juan at cuis.st>> wrote:
>>
>>         On 7/17/2024 11:08 AM, Mark Volkmann via Cuis-dev wrote:
>>>         When I enter the following lines in a Workspace, select
>>>         them, and "Do it", I get an AssertionFailure error:
>>>
>>>         str1 := 'test'.
>>>         str2 := 'test'.
>>>         self assert: str1 ~~ str2.
>>>
>>>         Ken, are you saying that you do not get that error?
>>>
>>>         -- 
>>>         R. Mark Volkmann
>>>         Object Computing, Inc.
>>
>>         Side comment: an AssertionFailure is an Exception but not an
>>         Error (see class hierarchy).
>>
>>         You get the AssertionFailure if you select all three lines
>>         and evaluate them together, but not if you evaluate them one
>>         by one.
>>
>>         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.
>>
>>         Cheers,
>>
>>         -- 
>>         Juan Vuletich
>>         cuis.st  <http://cuis.st>
>>         github.com/jvuletich  <http://github.com/jvuletich>
>>         researchgate.net/profile/Juan-Vuletich  <http://researchgate.net/profile/Juan-Vuletich>
>>         independent.academia.edu/JuanVuletich  <http://independent.academia.edu/JuanVuletich>
>>         patents.justia.com/inventor/juan-manuel-vuletich  <http://patents.justia.com/inventor/juan-manuel-vuletich>
>>         linkedin.com/in/juan-vuletich-75611b3  <http://linkedin.com/in/juan-vuletich-75611b3>
>>         twitter.com/JuanVuletich  <http://twitter.com/JuanVuletich>
>>
>>
>>
>>     -- 
>>     R. Mark Volkmann
>>     Object Computing, Inc.
>
>
>     -- 
>     Juan Vuletich
>     cuis.st  <http://cuis.st>
>     github.com/jvuletich  <http://github.com/jvuletich>
>     researchgate.net/profile/Juan-Vuletich  <http://researchgate.net/profile/Juan-Vuletich>
>     independent.academia.edu/JuanVuletich  <http://independent.academia.edu/JuanVuletich>
>     patents.justia.com/inventor/juan-manuel-vuletich  <http://patents.justia.com/inventor/juan-manuel-vuletich>
>     linkedin.com/in/juan-vuletich-75611b3  <http://linkedin.com/in/juan-vuletich-75611b3>
>     twitter.com/JuanVuletich  <http://twitter.com/JuanVuletich>
>
>     -- 
>     Cuis-dev mailing list
>     Cuis-dev at lists.cuis.st <mailto:Cuis-dev at lists.cuis.st>
>     https://lists.cuis.st/mailman/listinfo/cuis-dev
>


-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240717/70142849/attachment.htm>


More information about the Cuis-dev mailing list