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 <mail@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