guile-user
[Top][All Lists]
Advanced

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

Re: string is read-only


From: Thomas Morley
Subject: Re: string is read-only
Date: Wed, 3 Aug 2022 11:32:36 +0200

Am Mi., 3. Aug. 2022 um 11:13 Uhr schrieb Damien Mattei
<damien.mattei@gmail.com>:
>
> GNU Guile 3.0.1
> Copyright (C) 1995-2020 Free Software Foundation, Inc.
>
> Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
> This program is free software, and you are welcome to redistribute it
> under certain conditions; type `,show c' for details.
>
> Enter `,help' for help.
> 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"
>
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> ,q
> scheme@(guile-user)> (string? str2)
> #t
>
> is it a bug in Guile ? :-O
>
> i can only find reference to deprecated read-only string in old doc:
> https://www.gnu.org/software/guile/docs/docs-1.6/guile-ref/Read-Only-Strings.html#Read%20Only%20Strings
>
> Regards,
>
> Damien

Looks you need to do:

(define str2 (string-copy "hello"))
(string-set! str2 4 #\a)

Cheers,
  Harm



reply via email to

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