String literals -- e.g., the ones you can put in code -- are read-only by default. Dynamically constructed strings -- e.g., via #streamContents: -- are still writable. Change it via #beWritableObject if needed. Yet, better keep literal strings (and symbols) read-only. There used to be a time where those where cached in the CompiledMethod.

Best,
Marcel

Am 11.07.2023 15:26:16 schrieb Tim Rowledge <tim@rowledge.org>:

It looks like you need to examine methods like -

Object>>#beWritableObject
Object>>#setIsReadOnlyObject:
Object>>#attemptToAssign:withIndex:
Context>>#modificationForbiddenFor:instVarAt:put:
and the ModificationForbidden class.

As an example (that does pretty much what I expect but may not be strictly proper!) -

['dofigjdfgoidfdog' at: 5 put: $T; yourself]
on: ModificationForbidden
do: [:ex|
ex object beWritableObject.
ex retryModification]

If you know that you are going to madify something you might use

'dofigjdfgoidfdog' beWritableObject; at: 5 put: $T; yourself

> On 2023-07-11, at 12:27 PM, gettimothy via Squeak-dev wrote:
>
> My apologies if they always have been.
>
> UnixProccessAccessorTestCase >> #testArgsAsFlatArrayAndOffsets
>
> errors out on an attempt to modify a character in a ByteString.
>
>
> seems odd as I seem to recall being able to modify strings in the past.
>
>
> cordially,
>
> tty
>
>


tim
--
tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim
"Bo***x" said Pooh when Piglet kneed him in the groin.