unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* string is read-only
@ 2022-08-03  9:12 Damien Mattei
  2022-08-03  9:32 ` Thomas Morley
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Damien Mattei @ 2022-08-03  9:12 UTC (permalink / raw)
  To: guile-user, guile-devel

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

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

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  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:41 ` Maxime Devos
  2022-08-03  9:42 ` Taylan Kammer
  2 siblings, 1 reply; 15+ messages in thread
From: Thomas Morley @ 2022-08-03  9:32 UTC (permalink / raw)
  To: Damien Mattei; +Cc: guile-user, guile-devel

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



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03  9:12 string is read-only Damien Mattei
  2022-08-03  9:32 ` Thomas Morley
@ 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  9:42 ` Taylan Kammer
  2 siblings, 2 replies; 15+ messages in thread
From: Maxime Devos @ 2022-08-03  9:41 UTC (permalink / raw)
  To: Damien Mattei, guile-user, guile-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 1161 bytes --]


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 #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03  9:12 string is read-only Damien Mattei
  2022-08-03  9:32 ` Thomas Morley
  2022-08-03  9:41 ` Maxime Devos
@ 2022-08-03  9:42 ` Taylan Kammer
  2022-08-03  9:50   ` Jean Abou Samra
  2 siblings, 1 reply; 15+ messages in thread
From: Taylan Kammer @ 2022-08-03  9:42 UTC (permalink / raw)
  To: Damien Mattei, guile-user, guile-devel

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



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03  9:42 ` Taylan Kammer
@ 2022-08-03  9:50   ` Jean Abou Samra
  2022-08-03 10:30     ` Taylan Kammer
  0 siblings, 1 reply; 15+ messages in thread
From: Jean Abou Samra @ 2022-08-03  9:50 UTC (permalink / raw)
  To: Taylan Kammer; +Cc: Damien Mattei, guile-user, guile-devel



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

> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Fwd: string is read-only
       [not found]   ` <CADEOadctjXAyZfwYG3Qbky129i0NBbM+HK6g1iUwvA_HrT4UxA@mail.gmail.com>
@ 2022-08-03  9:51     ` Damien Mattei
  2022-08-03  9:59       ` Maxime Devos
  0 siblings, 1 reply; 15+ messages in thread
From: Damien Mattei @ 2022-08-03  9:51 UTC (permalink / raw)
  To: guile-devel, guile-user

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03  9:41 ` Maxime Devos
@ 2022-08-03  9:57   ` Ricardo G. Herdt
  2022-08-03 10:55   ` Damien Mattei
  1 sibling, 0 replies; 15+ messages in thread
From: Ricardo G. Herdt @ 2022-08-03  9:57 UTC (permalink / raw)
  To: guile-user, guile-devel

Hi,

Am 03.08.2022 11:41 schrieb Maxime Devos:
> 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:

R7RS has a chapter mentioning this (3.4. Storage Model).

Regards,

Ricardo



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Fwd: string is read-only
  2022-08-03  9:51     ` Fwd: " Damien Mattei
@ 2022-08-03  9:59       ` Maxime Devos
  0 siblings, 0 replies; 15+ messages in thread
From: Maxime Devos @ 2022-08-03  9:59 UTC (permalink / raw)
  To: Damien Mattei, guile-devel, guile-user


[-- Attachment #1.1.1: Type: text/plain, Size: 704 bytes --]


On 03-08-2022 11:51, Damien Mattei wrote:
> ok
> and i suppose it is the standard, i have been confused by other 
> schemes or racket where my code worked:

It happens to work in Guile too, when you use the interpreter instead of 
the compiler:

> scheme@(guile-user)> (eval `(let ((a ,(string-copy "foo"))) 
> (string-set! a 0 #\b) a) (current-module))
> $1 = "boo"
However, as implied by 
<https://lists.gnu.org/archive/html/guile-devel/2012-01/msg00135.html>, 
it's not something to rely upon.  (Maybe 'eval' should make all strings 
it encounters in the S-exp read-only first with substring/read-only, 
assuming that doesn't come with a performance cost.)

Greetings,
Maxime.


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03  9:50   ` Jean Abou Samra
@ 2022-08-03 10:30     ` Taylan Kammer
  2022-08-03 10:33       ` Jean Abou Samra
  0 siblings, 1 reply; 15+ messages in thread
From: Taylan Kammer @ 2022-08-03 10:30 UTC (permalink / raw)
  To: Jean Abou Samra; +Cc: Damien Mattei, guile-user, guile-devel

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.

-- 
Taylan



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03 10:30     ` Taylan Kammer
@ 2022-08-03 10:33       ` Jean Abou Samra
  0 siblings, 0 replies; 15+ messages in thread
From: Jean Abou Samra @ 2022-08-03 10:33 UTC (permalink / raw)
  To: Taylan Kammer; +Cc: Damien Mattei, guile-user, guile-devel



> 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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  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
  1 sibling, 1 reply; 15+ messages in thread
From: Damien Mattei @ 2022-08-03 10:55 UTC (permalink / raw)
  To: Maxime Devos; +Cc: guile-user, guile-devel

interesting the ELF file argument :-) ,i understand the idea, like a Turing
machine that  protect some part of ribbon...
it is the same thing with arrays
scheme@(guile-user)> (define vct '#(1 2 3))
scheme@(guile-user)> vct
#(1 2 3)
scheme@(guile-user)> (vector-set! vct 1 7)
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
In procedure vector-set!: Wrong type argument in position 1 (expecting
mutable vector): #(1 2 3)

works in Chicken scheme:
(define vct '#(1 2 3))
(vector-set! vct 1 7)

but no restrictions with lists in Guile:
scheme@(guile-user)> (define lst '(1 2 3))
scheme@(guile-user)> (set-car! lst 7)
scheme@(guile-user)> lst
(7 2 3)
which seems not logic.(but i recognize the behavior of Scheme of '80 even
if i no more use set-car! and set-cdr!)
Damien

On Wed, Aug 3, 2022 at 11:41 AM Maxime Devos <maximedevos@telenet.be> wrote:

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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03 10:55   ` Damien Mattei
@ 2022-08-03 10:59     ` Maxime Devos
  2022-08-03 11:34       ` Damien Mattei
  0 siblings, 1 reply; 15+ messages in thread
From: Maxime Devos @ 2022-08-03 10:59 UTC (permalink / raw)
  To: Damien Mattei; +Cc: guile-user, guile-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 684 bytes --]


On 03-08-2022 12:55, Damien Mattei wrote:
> but no restrictions with lists in Guile:
> scheme@(guile-user)> (define lst '(1 2 3))
> scheme@(guile-user)> (set-car! lst 7)
> scheme@(guile-user)> lst
> (7 2 3)

Non-empty lists are pairs and the second part of the pair is another 
list -- in Guile, this is effectively implement as having the second 
part (the cdr) be a kind of pointer.

Pointers need relocation, so lists cannot be put in read-only sections 
(unless something like RELRO is used), and in Guile pairs do not have 
'am I read-only' metadata (unlike strings).

(My unverified hypothesis on why you aren't seeing an error here.)

Greetings,
Maxime.


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03 10:59     ` Maxime Devos
@ 2022-08-03 11:34       ` Damien Mattei
  0 siblings, 0 replies; 15+ messages in thread
From: Damien Mattei @ 2022-08-03 11:34 UTC (permalink / raw)
  To: Maxime Devos; +Cc: guile-user, guile-devel

On Wed, Aug 3, 2022 at 12:59 PM Maxime Devos <maximedevos@telenet.be> wrote:

>
> (My unverified hypothesis on why you aren't seeing an error here.)
>
>
>  it would be a big change and very strange :-O if the few lines of code
below in scheme returned an error on lists:

but no restrictions with lists in Guile:
scheme@(guile-user)> (define lst '(1 2 3))
scheme@(guile-user)> (set-car! lst 7)
scheme@(guile-user)> lst
(7 2 3)

i wanted to add this link to my previous post:
https://icem.folkwang-uni.de/~finnendahl/cm_kurse/doc/schintro/schintro_38.html
it is interesting ,at the end of page it says too that modifying quoted
litteral should create an error :-O

Regards,
Damien


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
@ 2022-08-03 11:55 Pierpaolo Bernardi
  2022-08-03 12:48 ` Damien Mattei
  0 siblings, 1 reply; 15+ messages in thread
From: Pierpaolo Bernardi @ 2022-08-03 11:55 UTC (permalink / raw)
  To: Damien Mattei, Maxime Devos; +Cc: guile-user, guile-devel

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


Il giorno 3 agosto 2022, alle ore 13:36, Damien Mattei <damien.mattei@gmail.com> ha scritto:

>On Wed, Aug 3, 2022 at 12:59 PM Maxime Devos <maximedevos@telenet.be> wrote:
>>
>> (My unverified hypothesis on why you aren't seeing an error here.)
>>
>>
>>  it would be a big change and very strange :-O if the few lines of code
>below in scheme returned an error on lists:
>but no restrictions with lists in Guile:
>scheme@(guile-user)> (define lst '(1 2 3))
>scheme@(guile-user)> (set-car! lst 7)
>scheme@(guile-user)> lst
>(7 2 3)

This is illegal scheme. The  consequences of executing it are undefined.

It's unfortunate that because of implementation limitations many schemes do not detect this error.

>it is interesting ,at the end of page it says too that modifying quoted
>litteral should create an error :-O

It's how all Lisps, including guile, works.  So, yes, if one is interested in these languages, this is interesting knowledge :)


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: string is read-only
  2022-08-03 11:55 Pierpaolo Bernardi
@ 2022-08-03 12:48 ` Damien Mattei
  0 siblings, 0 replies; 15+ messages in thread
From: Damien Mattei @ 2022-08-03 12:48 UTC (permalink / raw)
  To: Pierpaolo Bernardi; +Cc: Maxime Devos, guile-user, guile-devel

>
> It's how all Lisps, including guile, works.  So, yes, if one is
> interested in these languages, this is interesting knowledge :)
>

Pierpaolo you sense of humour is tickling me :-)
i admit it is not common nowadays to set-car! or set-cdr! and my teachers
at the time i learn it
forbided it and only show it as example of bad coding in FP course .
Damien


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-08-03 12:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
2022-08-03 11:55 Pierpaolo Bernardi
2022-08-03 12:48 ` Damien Mattei

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