From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mike Gran Newsgroups: gmane.lisp.guile.devel Subject: Re: Guile: What's wrong with this? Date: Tue, 3 Jan 2012 19:04:38 -0800 (PST) Message-ID: <1325646278.7597.YahooMailNeo@web37902.mail.mud.yahoo.com> References: <4F027F35.5020001@gmail.com> <1325603029.22166.YahooMailNeo@web37906.mail.mud.yahoo.com> <4F032C41.3070300@gmail.com> <87mxa4ifux.fsf@gnu.org> Reply-To: Mike Gran 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 1325646291 2912 80.91.229.12 (4 Jan 2012 03:04:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 4 Jan 2012 03:04:51 +0000 (UTC) To: =?utf-8?B?THVkb3ZpYyBDb3VydMOocw==?= , "guile-devel@gnu.org" Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jan 04 04:04:47 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 1RiH9g-0006LS-MU for guile-devel@m.gmane.org; Wed, 04 Jan 2012 04:04:44 +0100 Original-Received: from localhost ([::1]:59435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiH9g-0000rr-2M for guile-devel@m.gmane.org; Tue, 03 Jan 2012 22:04:44 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:58427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiH9d-0000rb-HP for guile-devel@gnu.org; Tue, 03 Jan 2012 22:04:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RiH9b-0004m8-G5 for guile-devel@gnu.org; Tue, 03 Jan 2012 22:04:41 -0500 Original-Received: from nm27-vm0.bullet.mail.ac4.yahoo.com ([98.139.52.244]:23311) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RiH9b-0004lr-CD for guile-devel@gnu.org; Tue, 03 Jan 2012 22:04:39 -0500 Original-Received: from [98.139.52.188] by nm27.bullet.mail.ac4.yahoo.com with NNFMP; 04 Jan 2012 03:04:39 -0000 Original-Received: from [98.139.52.187] by tm1.bullet.mail.ac4.yahoo.com with NNFMP; 04 Jan 2012 03:04:39 -0000 Original-Received: from [127.0.0.1] by omp1070.mail.ac4.yahoo.com with NNFMP; 04 Jan 2012 03:04:39 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 88912.36807.bm@omp1070.mail.ac4.yahoo.com Original-Received: (qmail 11846 invoked by uid 60001); 4 Jan 2012 03:04:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1325646278; bh=9nNfUZ4j1PlbmtjE+O6KtfEPAZxBuXbDaDOGcfSrI0M=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=W3XIu3l8Wse/9MPhISl9Kiuyuizg5T1LAf92ws9INO8jIOjV6l87r8sWxajENFeq1+H7w+0BATZ/QsqC2xa19abTnDxnBa8oL566uMJP3ptGANpuJKFOseND7vTpvcDpL/Xpq7QFJR3pKf6Q1NtYt5mz+8ZWHdXYmjI8Betb4UQ= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=QZ03g2TkP+dKyE6+mJ6+fLHzLeoQKajZTaU+WKPN3tgH5RPTeFL/jf4clNIG30uXVff5Pe2diGful8ZFmO1+P10FIPApDpfMUbpOjTab0sdM6ZRQS/X/FqdqD4UAlwcRbr5tB7c5HnTrGaTdjbF1hhCclaf42ZHNE+WrPFNLIBI=; X-YMail-OSG: Pya6DaYVM1laB_K4PjfxZxPta30XqA1owpWI4iU0mayq2dV VX4JVDUTcpxzVo5pQv1gUY_vHwlssKMYsfxrbFA3VVtYgQSlwuCJebFjVlFA Ypt6nadR5rY11R5_p9GMii4CWNo.nI.7HBDT62Y7dyH0EHR6YaWwsvv1IFQy ab44ZNyIuLGO7b5Ylg0bV.1DDfs.4GSCisXGLr8NjJoGTtT20O9BlHaVwpWL CJBNniflieW.8fRwYXaGJz2B4f4mXmsLoTkpvzQgnvlLPMOqG24veG0XLt_j F.ZDOIpvDKvfyxY40oKE4vWFFFf.DbpmCK.X6jjVM.Ylhu0Cns7pyrgendqw In3tSyu_uagRawnFWskU83egAXjxIan11zFehTNdulIx8WFwRKExoX70wv_Z 8JTrZfTZWTM.mJuL4Q8US3rYycdSGQ00MsG.7ASXOOpUDzyOTiNwQA_bi_Mm hBCgj6.wMumwKOokCqlYl Original-Received: from [71.130.216.67] by web37902.mail.mud.yahoo.com via HTTP; Tue, 03 Jan 2012 19:04:38 PST X-Mailer: YahooMailWebService/0.8.115.331698 In-Reply-To: <87mxa4ifux.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 98.139.52.244 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:13255 Archived-At: > =C2=A0 In many systems it is desirable for constants (i.e. the values of = literal=0A> =C2=A0 expressions) to reside in read-only-memory.=C2=A0 To exp= ress this, it is=0A> =C2=A0 convenient to imagine that every object that de= notes locations is=0A> =C2=A0 associated with a flag telling whether that o= bject is mutable or immutable.=0A> =C2=A0 In such systems literal constants= and the strings returned by=0A> =C2=A0 `symbol->string' are immutable obje= cts, while all objects created by=0A> =C2=A0 the other procedures listed in= this report are mutable.=C2=A0 It is an error=0A> =C2=A0 to attempt to sto= re a new value into a location that is denoted by an=0A> =C2=A0 immutable o= bject.=0A> =0A> In Guile this has been the case since commit=0A> 190d4b0d93= 599e5b58e773dc6375054c3a6e3dbf.=0A> =0A> The reason for this is that Guile= =E2=80=99s compiler tries hard to avoid=0A> duplicating constants in the ou= tput bytecode.=C2=A0 Thus, modifying a=0A> constant would actually change a= ll other occurrences of that constant in=0A> the code, making it a non-cons= tant.=C2=A0 ;-)=0A=0AThis is a terrible example of the RnRS promoting some = strange idea of=0Amathematical purity over being useful.=0A=C2=A0=0AThe ide= a that the correct way to initialize a string is=0A(define x (string-copy "= string")) is awkward.=C2=A0 "string" is a read-only=0Abut copying it makes = it modifyiable?=C2=A0 Copying implies mutability?=0A=C2=A0=0ACopying doesn'= t imply modifying mutability in any other data type.=0A=C2=A0=0AWhy not=C2= =A0change the behavior=C2=A0'define' to be (define y (substring str 0)) whe= n STR=0Ais a read-only string?=C2=A0 This would preserve the shared memory = if the variable is never=0Amodified but still make the string copy-on-write= .=0A=C2=A0=0ARegards,=0A=C2=A0=0AMike