Hello Sven, thank you very much for this thorough explanation! I also think a string literal should be a constant.
But since I am new to Smalltalk I am reading a lot of documentation, and in the older documentation modification of a string was shown as an example. In fact this modification is still possible in Pharo 8. But I am all for progress and evolution of Smalltalk for the better and this is how it was meant to be by it’s inventors. Again thank you very much for your time Markus Von meinem iPad gesendet > Am 28.02.2021 um 10:57 schrieb Sven Van Caekenberghe <s...@stfx.eu>: > > Markus, > > 'hello' is a literal string constant, part of the set of constants of a > method (or a doit which like a temporary method disconnected from a class). > > Constants like these are managed by the compiler and can be shared between > different expressions to avoid duplication. > > Changing such a constant is dangerous because it means you are changing > static/compiled code. Consider a method like > > name > ^ 'Markus' > > I could call this method and change the returned string destructively in > place. Next time someone calls it, s/he would get the modified string. Even > worse, s/he would not understand since the source code did not change. > > In the past it was not possible to mark such strings as being constant, now > we can. Which is a big win. > > You can use #copy to get a string that you can modify. > > 'hello' copy at: 2 put: $a; yourself > > HTH, > > Sven > >> On 28 Feb 2021, at 00:50, Markus Wedel <m...@markus-wedel.de> wrote: >> >> Hi all, >> >> strings in Playground are read only in Pharo 9.0 Build 1153 so that >> >> 'hello' at: 2 put: $a; yourself >> ctrl+p >> >> This throws an error: >> „Modification forbidden: ‚hello‘ is read-only, hence its field cannot be >> modified with $a >> >> which is actually a very nice error message but is this supposed to happen? >> The example does work in Pharo 8 without problems. >> >> >> Greetings >> Markus