For what it's worth, the ANSI Smalltalk standard says
"The protocols specified for literals do not include any messages
��that modify the state of the literal objects.
��The effect of sending a message to an object that is the value
��of a literal that modifies the state of the literal is undefined."
This also includes trying to modify an array literal, and fiddling
with the bits of a large integer.

That is, according to the ANSI standard, 'abc' is a string but not
necessarily a String.�� I hope that is clear (:-).


On Sun, 28 Feb 2021 at 22:57, Sven Van Caekenberghe <sven@stfx.eu> wrote:
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