From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Fwd: string is read-only Date: Wed, 3 Aug 2022 11:51:49 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000035c8fc05e5532f6b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19578"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel , guile-user Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Aug 03 11:55:07 2022 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oJB5n-0004xe-Bb for guile-devel@m.gmane-mx.org; Wed, 03 Aug 2022 11:55:07 +0200 Original-Received: from localhost ([::1]:40990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJB5m-0000wF-3u for guile-devel@m.gmane-mx.org; Wed, 03 Aug 2022 05:55:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJB2r-0007PC-En; Wed, 03 Aug 2022 05:52:05 -0400 Original-Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:45637) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJB2p-0002HI-Bg; Wed, 03 Aug 2022 05:52:05 -0400 Original-Received: by mail-lf1-x130.google.com with SMTP id a9so12828948lfm.12; Wed, 03 Aug 2022 02:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc; bh=OeNpDUDBgYwB2WDTSQ3TuoLzUmwlobIJ1wYoEJrfv0U=; b=kE0y2wn4oG3eNh7vwVmBirFlVPR/m4LRRGYiQwPIu8dhWmZAhZAXOZ53GPCm1WYP5w sEZ7jtqOW/X9USPI5RF7WqcyJW3QR8hTp7NhBeW/1I2/h1LZZaIADZ70fNGgKP2tgcFk 4nUn41iRQQGObfSOsxrRtCmb+j2CeNoDoxS2VOBe+eVgA2PQXBp2T7wM3nRrIU67p2FT 9Gn1wmoOUWDvTocMWrb2aXbR9Lk5wSErzkH1X9iLMILSrTQVsA4mWk9fdFNNb3PK0EW3 U1/VTjN3GGnTjrfdVzsw5voUIMMH31qKHoH5vMalzVHC1t+ovL7rZnS0jXJQMMXdSB6a 4XOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc; bh=OeNpDUDBgYwB2WDTSQ3TuoLzUmwlobIJ1wYoEJrfv0U=; b=o+nAdpb4rmc4yriLYhECTPwhtovSzfYzVtVYYhaSHUWIGPCho7ACVLc+jiZ1LGQL4b KRZWri0lrgDkv03/6FSHxLMo105838IVUqtlYOTMjCDPKHi0GAC/dsosNanDWnfp5AAs 3Qpf4unv/d273yoWqLsBAxOZOZ2Ge0VXfYEitia5VSn55pIUF7K89pk/4OMq/KZEThKT IWErdxwxDgYV1nYFmEasuhaf18lLHjtJfd56i9uqy+iGD9SKj6oZ/MgOf8Z3bQO4Co0f adtpLND6qGI4iL55BLPnstfgxn9pnihzUuNSPiuFUxmdjc1D7uCcLxekyW7Oh/QCPx4z efsQ== X-Gm-Message-State: ACgBeo1RfEhmMCiKWZQt8u7/joMQ/5bxQ8ZozybGO4cyqvOPQtj8svn8 GQ3j4wgXpRJA8Wh3M+D0mCdsddQFztN2oYC2wloge5Dh X-Google-Smtp-Source: AA6agR7Gx/eIYuT0FAPBaxZFPK7Y9ghrUTgdR6axriOQU62MMsmmcNcIILkJcErmVhgYXenbJA5AJh35M2zzLCQ/2+A= X-Received: by 2002:a05:6512:3a8e:b0:48b:b6a:e670 with SMTP id q14-20020a0565123a8e00b0048b0b6ae670mr2407505lfu.40.1659520320652; Wed, 03 Aug 2022 02:52:00 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=damien.mattei@gmail.com; helo=mail-lf1-x130.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21280 gmane.lisp.guile.user:18474 Archived-At: --00000000000035c8fc05e5532f6b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ---------- Forwarded message --------- From: Damien Mattei Date: Wed, Aug 3, 2022 at 11:51 AM Subject: Re: string is read-only To: Thomas Morley 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=C3=A9moire : 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 # 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 wrote: > Am Mi., 3. Aug. 2022 um 11:13 Uhr schrieb Damien Mattei > : > > > > 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-Stri= ngs.html#Read%20Only%20Strings > > > > Regards, > > > > Damien > > Looks you need to do: > > (define str2 (string-copy "hello")) > (string-set! str2 4 #\a) > > Cheers, > Harm > --00000000000035c8fc05e5532f6b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

---------- Forwarded message ---------
From: Damien Mattei <damien.mattei@gmail.com>
Date: W= ed, Aug 3, 2022 at 11:51 AM
Subject: Re: string is read-only
To: Thom= as Morley <thomasmorley65@gm= ail.com>


ok
and i suppose it is the standa= rd, i have been confused by other schemes or racket where my code worked:
CHICKEN
(c) 2008-2019, The CHICKEN Te= am
(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=C3=A9moire : 128 MB.
> (define str2 "hello")
> (string-set! str2 4= #\a)
. . string-set!: contract violation
=C2=A0 expected: (and/c str= ing? (not/c immutable?))
=C2=A0 given: "hello"
=C2=A0 argum= ent position: 1st
=C2=A0 other arguments...:
> string-copy
#<= ;procedure:string-copy>

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

scheme@(guile-user)> (use-modu= les (Scheme+))
scheme@(guile-user)> {str <+ (string-copy "hel= lo")}
"hello"
scheme@(guile-user)> {str[4]}
#\o<= br>scheme@(guile-user)> {str[4] <- #\a}
#\a
scheme@(guile-user)= > str
"hella"

<= /div>
thanks
Damien


On Wed, Aug 3,= 2022 at 11:32 AM Thomas Morley <thomasmorley65@gmail.com> wrote:
Am Mi., 3. Aug. 2022 um 11:1= 3 Uhr schrieb Damien Mattei
<damien.mat= tei@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<= br> > 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.=C2=A0 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-Onl= y-Strings.html#Read%20Only%20Strings
>
> Regards,
>
> Damien

Looks you need to do:

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

Cheers,
=C2=A0 Harm
--00000000000035c8fc05e5532f6b--