From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: Guile: What's wrong with this? Date: Thu, 05 Jan 2012 17:42:51 -0500 Message-ID: <878vlldb4k.fsf@netris.org> References: <4F027F35.5020001@gmail.com> <1325603029.22166.YahooMailNeo@web37906.mail.mud.yahoo.com> <4F032C41.3070300@gmail.com> <87mxa4ifux.fsf@gnu.org> <4F038BF4.1070200@gnu.org> <87obujzmmc.fsf@Kagami.home> <4F048972.5040803@gnu.org> <87lipnm8yx.fsf@Kagami.home> <4F04D01D.5050801@gnu.org> <8762grf28k.fsf@netris.org> <4F05DC47.1000202@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1325803401 18213 80.91.229.12 (5 Jan 2012 22:43:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 Jan 2012 22:43:21 +0000 (UTC) Cc: guile-devel@gnu.org To: Bruce Korb Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jan 05 23:43:17 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 1Riw1k-0001tW-4G for guile-devel@m.gmane.org; Thu, 05 Jan 2012 23:43:16 +0100 Original-Received: from localhost ([::1]:34954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Riw1j-0007V9-6s for guile-devel@m.gmane.org; Thu, 05 Jan 2012 17:43:15 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:38853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Riw1h-0007V3-2J for guile-devel@gnu.org; Thu, 05 Jan 2012 17:43:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Riw1f-00034J-UK for guile-devel@gnu.org; Thu, 05 Jan 2012 17:43:12 -0500 Original-Received: from world.peace.net ([96.39.62.75]:40041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Riw1f-00034A-QY; Thu, 05 Jan 2012 17:43:11 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1Riw1a-00070O-3A; Thu, 05 Jan 2012 17:43:06 -0500 In-Reply-To: <4F05DC47.1000202@gnu.org> (Bruce Korb's message of "Thu, 05 Jan 2012 09:22:15 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 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:13332 Archived-At: Bruce Korb writes: > Anyway, such a concept should be kept > very simple: functions that modify their argument make copies of > any input argument that is read only. Any other SCM's lying about > that refer to the unmodified object continue referring to that > same unmodified object. No mind reading required. > > (define a "hello") > (define b a) > (string-upcase! a) > b I suspect that what you really want is for `define' (and maybe some other things) to automatically do a deep copy instead of merely making a new reference to an existing object. For example, you seem to want (define a "hello") to make a fresh copy of the string literal, and for (define b a) to make another copy so that changes to the string referenced by `b' do not affect the string referenced by `a'. You seem to not want to think about aliasing issues. Indeed, it would be more intuitive if we always copied everything deeply, but that would be strictly less powerful, not to mention far less efficient, especially when handling large structures. `define' merely makes a new reference to an existing object. If you want a copy, you must explicitly ask for one (though this could be hidden by custom syntax). It would not be desirable for the language to make copies automatically as part of the core `define' syntax. For one thing, sometimes you don't want a copy. Sometimes you want shared mutable objects. Even if you do want to copy, there are different kinds of copies. How deeply do you want to copy? If it's a hierarchical list, do you want to copy only the first level of the list, or do you want to recurse? Suppose this hierarchical list contains strings. Do you want to copy the strings too, or just the list structure? I could go on and on. There's no good universal copier; it depends on your purposes. If you want an abbreviated way to both `define' and `copy', then you'll need to make new syntax to do that. Guile provides all the power you need to do this. Mark