From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Guile: What's wrong with this? Date: Wed, 04 Jan 2012 22:07:58 +0100 Message-ID: <874nwbdvm9.fsf@gnu.org> References: <4F027F35.5020001@gmail.com> <1325603029.22166.YahooMailNeo@web37906.mail.mud.yahoo.com> <4F032C41.3070300@gmail.com> <87mxa4ifux.fsf@gnu.org> <1325646278.7597.YahooMailNeo@web37902.mail.mud.yahoo.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1325711291 14827 80.91.229.12 (4 Jan 2012 21:08:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 4 Jan 2012 21:08:11 +0000 (UTC) Cc: "guile-devel@gnu.org" To: Mike Gran Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jan 04 22:08:07 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RiY46-000524-IJ for guile-devel@m.gmane.org; Wed, 04 Jan 2012 22:08:06 +0100 Original-Received: from localhost ([::1]:35087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiY45-0000MN-UM for guile-devel@m.gmane.org; Wed, 04 Jan 2012 16:08:05 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:46981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiY43-0000ME-DT for guile-devel@gnu.org; Wed, 04 Jan 2012 16:08:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RiY42-0002G3-8Y for guile-devel@gnu.org; Wed, 04 Jan 2012 16:08:03 -0500 Original-Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]:56155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiY42-0002FN-45 for guile-devel@gnu.org; Wed, 04 Jan 2012 16:08:02 -0500 X-IronPort-AV: E=Sophos;i="4.71,458,1320620400"; d="scan'208";a="137875735" Original-Received: from reverse-83.fdn.fr (HELO pluto) ([80.67.176.83]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 04 Jan 2012 22:08:00 +0100 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 15 =?iso-8859-1?Q?Niv=F4se?= an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: <1325646278.7597.YahooMailNeo@web37902.mail.mud.yahoo.com> (Mike Gran's message of "Tue, 3 Jan 2012 19:04:38 -0800 (PST)") User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.134.164.82 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13299 Archived-At: Hi! Mike Gran skribis: >> =C2=A0 In many systems it is desirable for constants (i.e. the values of= literal >> =C2=A0 expressions) to reside in read-only-memory.=C2=A0 To express this= , it is >> =C2=A0 convenient to imagine that every object that denotes locations is >> =C2=A0 associated with a flag telling whether that object is mutable or = immutable. >> =C2=A0 In such systems literal constants and the strings returned by >> =C2=A0 `symbol->string' are immutable objects, while all objects created= by >> =C2=A0 the other procedures listed in this report are mutable.=C2=A0 It = is an error >> =C2=A0 to attempt to store a new value into a location that is denoted b= y an >> =C2=A0 immutable object. [...] > The idea that the correct way to initialize a string is > (define x (string-copy "string")) is awkward.=C2=A0 "string" is a read-on= ly > but copying it makes it modifyiable?=C2=A0 Copying implies mutability? Sort-of: -- library procedure: string-copy string Returns a newly allocated copy of the given STRING. And a =E2=80=9Cnew allocated copy=E2=80=9D is mutable. > Copying doesn't imply modifying mutability in any other data type. It=E2=80=99s not about modifying mutability of an object (this can=E2=80=99= t be done), but about fresh vs. constant storage. > Why not=C2=A0change the behavior=C2=A0'define' to be (define y (substring= str 0)) when STR > is a read-only string?=C2=A0 This would preserve the shared memory if the= variable is never > modified but still make the string copy-on-write. I think all sorts of literal strings would have to be treated the same. FTR, all these evaluate to #t: (apply eq? "hello" '("hello")) (apply eq? '(1 2 3) '((1 2 3))) (apply eq? '#(1 2 3) '(#(1 2 3))) This is fine per R5RS (info "(r5rs) Equivalence predicates"), but different from Guile <=3D 1.8. (I use =E2=80=98apply=E2=80=99 here to fool peval, which otherwise evaluate= s the expressions to #f at compile-time. Andy: should peval be hacked to give the same answer?) Thanks, Ludo=E2=80=99.