unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Damien Mattei <damien.mattei@gmail.com>
To: guile-devel <guile-devel@gnu.org>, guile-user <guile-user@gnu.org>
Subject: Fwd: string is read-only
Date: Wed, 3 Aug 2022 11:51:49 +0200	[thread overview]
Message-ID: <CADEOadcArxQevHcS3N=CCMa4VHq7qJY9ifUpCS1LRo4Sx0VP-Q@mail.gmail.com> (raw)
In-Reply-To: <CADEOadctjXAyZfwYG3Qbky129i0NBbM+HK6g1iUwvA_HrT4UxA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2564 bytes --]

---------- Forwarded message ---------
From: Damien Mattei <damien.mattei@gmail.com>
Date: Wed, Aug 3, 2022 at 11:51 AM
Subject: Re: string is read-only
To: Thomas Morley <thomasmorley65@gmail.com>


ok
and i suppose it is the standard, i have been confused by other schemes or
racket where my code worked:
CHICKEN
(c) 2008-2019, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 5.1.0 (rev 8e62f718)
linux-unix-gnu-x86-64 [ 64bit dload ptables ]

#;1> 3
3
#;2> (define str2 "hello")
#;3> (string-set! str2 4 #\a)
#;4> str2
"hella"

but not with Racket and #lang R5RS:
Bienvenue dans DrRacket, version 7.7 [3m].
Langage: R5RS; limite mémoire : 128 MB.
> (define str2 "hello")
> (string-set! str2 4 #\a)
. . string-set!: contract violation
  expected: (and/c string? (not/c immutable?))
  given: "hello"
  argument position: 1st
  other arguments...:
> string-copy
#<procedure:string-copy>

not in Gauche scheme too...
and as i making string supported by my Scheme+ i had doubt about it also
:-) but it works well :

scheme@(guile-user)> (use-modules (Scheme+))
scheme@(guile-user)> {str <+ (string-copy "hello")}
"hello"
scheme@(guile-user)> {str[4]}
#\o
scheme@(guile-user)> {str[4] <- #\a}
#\a
scheme@(guile-user)> str
"hella"

thanks
Damien


On Wed, Aug 3, 2022 at 11:32 AM Thomas Morley <thomasmorley65@gmail.com>
wrote:

> 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
>

[-- Attachment #2: Type: text/html, Size: 4370 bytes --]

  parent reply	other threads:[~2022-08-03  9:51 UTC|newest]

Thread overview: 13+ 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     ` Damien Mattei [this message]
2022-08-03  9:59       ` Fwd: " 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

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='CADEOadcArxQevHcS3N=CCMa4VHq7qJY9ifUpCS1LRo4Sx0VP-Q@mail.gmail.com' \
    --to=damien.mattei@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    /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).