unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Jean Abou Samra <jean@abou-samra.fr>
To: Taylan Kammer <taylan.kammer@gmail.com>
Cc: Damien Mattei <damien.mattei@gmail.com>,
	guile-user <guile-user@gnu.org>,
	guile-devel <guile-devel@gnu.org>
Subject: Re: string is read-only
Date: Wed, 3 Aug 2022 12:33:59 +0200	[thread overview]
Message-ID: <B5E2ED15-34B9-440B-AE37-3012880A3715@abou-samra.fr> (raw)
In-Reply-To: <0474dc97-a009-7d0c-8fc8-fe831f13223a@gmail.com>



> Le 3 août 2022 à 12:30, Taylan Kammer <taylan.kammer@gmail.com> a écrit :
> 
> On 03.08.2022 11:50, Jean Abou Samra wrote:
>> 
>> 
>>>> Le 3 août 2022 à 11:49, Taylan Kammer <taylan.kammer@gmail.com> a écrit :
>>> 
>>> On 03.08.2022 11:12, Damien Mattei wrote:
>>>> 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 <https://www.gnu.org/software/guile/docs/docs-1.6/guile-ref/Read-Only-Strings.html#Read%20Only%20Strings>
>>>> 
>>>> Regards,
>>>> 
>>>> Damien
>>> 
>>> String literals are constants, and it's intentional.
>>> 
>>> I'm not sure if it's mentioned anywhere in the manual.
>>> 
>>> If you want to get a mutable string from a literal, you can use:
>>> 
>>>  (define str (string-copy "foobar"))
>>> 
>>> -- 
>>> Taylan
>> 
>> This is standard. See the intro of
>> 
>> https://srfi.schemers.org/srfi-135/ <https://srfi.schemers.org/srfi-135/>
>> 
>>> 
> 
> This SRFI defines a new data type, which is not really relevant here.
> 
> As far as I know, Guile doesn't support it yet anyway.



I just wanted to point to the intro, which summarizes the state of literal string immutability in all recent RnRSes:

"""
In Scheme, strings are a mutable data type. Although it "is an error" (R5RS and R7RS) to use string-set! on literal strings or on strings returned by symbol->string, and any attempt to do so "should raise an exception" (R6RS),
"""



> -- 
> Taylan


  reply	other threads:[~2022-08-03 10:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03  9:12 string is read-only Damien Mattei
2022-08-03  9:32 ` Thomas Morley
     [not found]   ` <CADEOadctjXAyZfwYG3Qbky129i0NBbM+HK6g1iUwvA_HrT4UxA@mail.gmail.com>
2022-08-03  9:51     ` Fwd: " Damien Mattei
2022-08-03  9:59       ` Maxime Devos
2022-08-03  9:41 ` Maxime Devos
2022-08-03  9:57   ` Ricardo G. Herdt
2022-08-03 10:55   ` Damien Mattei
2022-08-03 10:59     ` Maxime Devos
2022-08-03 11:34       ` Damien Mattei
2022-08-03  9:42 ` Taylan Kammer
2022-08-03  9:50   ` Jean Abou Samra
2022-08-03 10:30     ` Taylan Kammer
2022-08-03 10:33       ` Jean Abou Samra [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-08-03 11:55 Pierpaolo Bernardi
2022-08-03 12:48 ` Damien Mattei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B5E2ED15-34B9-440B-AE37-3012880A3715@abou-samra.fr \
    --to=jean@abou-samra.fr \
    --cc=damien.mattei@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=taylan.kammer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).