guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string is read-only


From: Maxime Devos
Subject: Re: string is read-only
Date: Wed, 3 Aug 2022 11:41:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0


On 03-08-2022 11:12, Damien Mattei wrote:
scheme@(guile-user)> (define str2 "hello")
scheme@(guile-user)> (string-set! str2 4 #\a)
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
string is read-only: "hello"

It's not -- the existence of read-only strings is implied by substring/read-only, and also see:

  (guile)Object File format
Typically all segments of an ELF file are marked as read-only, except
that part that represents modifiable static data or static data that
needs load-time initialization.  Loading an ELF file is as simple as
mmapping the thing into memory with read-only permissions, then using
the segment table to mark a small sub-region of the file as writable.
This writable section is typically added to the root set of the garbage
collector as well.

I'm not aware of explicit documentation that string literals may not be modified (and in this case, cannot be modified). However, see the following mail on string mutability and program text:

https://lists.gnu.org/archive/html/guile-devel/2012-01/msg00135.html

and maybe surrounding definitions.

Greetings,
Maxime.

Attachment: OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]