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.user,gmane.lisp.guile.devel Subject: Re: string is read-only Date: Wed, 3 Aug 2022 12:55:02 +0200 Message-ID: References: <8294f792-cdb6-46a4-899a-f0a23e67b249@telenet.be> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31371"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user , guile-devel To: Maxime Devos Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 03 12:55:42 2022 Return-path: Envelope-to: guile-user@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 1oJC2P-0007uk-8s for guile-user@m.gmane-mx.org; Wed, 03 Aug 2022 12:55:41 +0200 Original-Received: from localhost ([::1]:49934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJC2N-0006FX-Rf for guile-user@m.gmane-mx.org; Wed, 03 Aug 2022 06:55:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJC22-0006Eb-Ks; Wed, 03 Aug 2022 06:55:18 -0400 Original-Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:35718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJC20-0008Np-JB; Wed, 03 Aug 2022 06:55:18 -0400 Original-Received: by mail-lf1-x134.google.com with SMTP id z25so25871518lfr.2; Wed, 03 Aug 2022 03:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=mvlFOUPwdnkfJ4iRd+oPUCSsj8i/MRSjDObF9fAhdog=; b=jNk8oQe3qJFZV3z/M4Vf3OTpu3c7QDlMRRoGW31bzzzmmQoUDFYP4hQF5xey4FnFNZ qVKQsLqJI2KPgSJTLDy353iOZIOLVtBHnaaTg9kQ2S/J/oM1jfBWkSOeGNtO9RQVX9n+ dz2GuvxV8TQrPwwZm4EdzM1VQ8KcfkiernaKoQ8IIfK/2m2GPrNe2Nq9s3nrQpWUXdzl +NFkifVLTHn4azGswmN5LHoNl/t+LTZFWctdNtTxnFDHH9F67hn9UmkHlN1kSR2XWkI+ FlIT3smqJ3tv23dP5gAq9DpXizKA4H5hys39FWxfQrWT7ymBfWhu8D8RPzrV62hZf8jm eC5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=mvlFOUPwdnkfJ4iRd+oPUCSsj8i/MRSjDObF9fAhdog=; b=sl/5M3lFN/4oGKk1TGL2y2iYkb/fn9J3YuLN0IEBiT5oUgqb1ksJ0ddQIjQzQNVP2F WeLJ3pM5zruc3MKGLi48RX24ndFRAGF3Jfe6XCN032BbSW4BUFHylXXZQnoAySBl9xf3 Go8mh1EvDqbS8A3uk7F8J8yBdsdpir2iln6Mx7fkdxRpS5fKVyaFYkhpD3+ORz+xOvup pPgJC4SgruLrOHplk29OSP8IdlIwvICiyIMgYXCz7U9DRL425Uv5TXifE2/+QDDkHiAh +smiupGGuA/BI8FntN2D9Tp6fE74lJBcglWaZYPmnIB/Mwpd0BxhsAUR/XTF1N7sBQ/j oKBQ== X-Gm-Message-State: AJIora+K79GQu1Yzw0v2iF8Y1CzjNK0b4Qstv1v6cGwOU4zP0NJcimMz +fFsdBhfiOh8TRhGm5d/XHOtHCAAP/GVi57njTY= X-Google-Smtp-Source: AGRyM1umYgvNOPNJLBLJHWqawI+IutGUX3vuAOogUWBDJ/4p0tvWuzYc5EMYIiLOYS1MtKZ/AGYJ2ouNOBDTCXqX1ZM= X-Received: by 2002:a05:6512:2290:b0:48a:9b0c:e12a with SMTP id f16-20020a056512229000b0048a9b0ce12amr9839176lfu.616.1659524114232; Wed, 03 Aug 2022 03:55:14 -0700 (PDT) In-Reply-To: <8294f792-cdb6-46a4-899a-f0a23e67b249@telenet.be> Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=damien.mattei@gmail.com; helo=mail-lf1-x134.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-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:18480 gmane.lisp.guile.devel:21286 Archived-At: 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 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. > >