unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Damien Mattei <damien.mattei@gmail.com>
To: Maxime Devos <maximedevos@telenet.be>
Cc: guile-user <guile-user@gnu.org>, guile-devel <guile-devel@gnu.org>
Subject: Re: string is read-only
Date: Wed, 3 Aug 2022 12:55:02 +0200	[thread overview]
Message-ID: <CADEOade2yJejoXkOKPojRF_N8DpkK934TozevdM0AHA6Qxh-JQ@mail.gmail.com> (raw)
In-Reply-To: <8294f792-cdb6-46a4-899a-f0a23e67b249@telenet.be>

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


  parent reply	other threads:[~2022-08-03 10:55 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 [this message]
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

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=CADEOade2yJejoXkOKPojRF_N8DpkK934TozevdM0AHA6Qxh-JQ@mail.gmail.com \
    --to=damien.mattei@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=maximedevos@telenet.be \
    /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).