From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Maciek Godek" Newsgroups: gmane.lisp.guile.user Subject: Re: References/locations Date: Fri, 15 Aug 2008 12:14:05 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1218795287 19808 80.91.229.12 (15 Aug 2008 10:14:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Aug 2008 10:14:47 +0000 (UTC) Cc: guile-user@gnu.org To: "Kjetil S. Matheussen" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Aug 15 12:15:40 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KTwLL-0007BV-HQ for guile-user@m.gmane.org; Fri, 15 Aug 2008 12:15:39 +0200 Original-Received: from localhost ([127.0.0.1]:42537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTwKM-0003hc-Dl for guile-user@m.gmane.org; Fri, 15 Aug 2008 06:14:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KTwJv-0003gw-VD for guile-user@gnu.org; Fri, 15 Aug 2008 06:14:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KTwJt-0003fy-1v for guile-user@gnu.org; Fri, 15 Aug 2008 06:14:10 -0400 Original-Received: from [199.232.76.173] (port=45143 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTwJr-0003fm-0B for guile-user@gnu.org; Fri, 15 Aug 2008 06:14:07 -0400 Original-Received: from wf-out-1314.google.com ([209.85.200.168]:28240) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KTwJq-0006zW-Ii for guile-user@gnu.org; Fri, 15 Aug 2008 06:14:06 -0400 Original-Received: by wf-out-1314.google.com with SMTP id 28so884015wfc.24 for ; Fri, 15 Aug 2008 03:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=VlqdS3JowCcFbSDbyMCBOJeuV+d4A2EW5DAB/h9zjq0=; b=lGL6Z/9fUJSSZyF12Ce6QLPa3zHNtzYlIA9yAupO425Ho93NoKaIsIE4SxAczkxKBA UyxFn+VXarNEf+s8ZIFw6BlpNO6NFN8J2Hf7GnKxQsPOvn3Yj4HMdPxzVT8IRPMtir99 8eVeP1Tp90jNxr9/ROOBTQfCxWNca9Zkgea0w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=N5pdhCCSl0UbmG02mWdG0ixAyPi+1lOocu1qe21mEvGeXMCyPs9lOIgB+tIFrpNkgs v3P8D3V8IGVEgiosT/XKeMDGMBrvv9UxRLLdiWyYJuRNb3pihH39G9fL7iMCIB7X4X/M oEWo+qhxA7kwxYryr/oYY+cW8H2vzMy8gbju0= Original-Received: by 10.142.142.14 with SMTP id p14mr921979wfd.114.1218795245649; Fri, 15 Aug 2008 03:14:05 -0700 (PDT) Original-Received: by 10.142.164.4 with HTTP; Fri, 15 Aug 2008 03:14:05 -0700 (PDT) In-Reply-To: Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6749 Archived-At: Kjetil: > Well, here's a relatively clean way, I think: > > (define-macro (location name) > (define new-val (gensym)) > `(lambda (,new-val) > (set! ,name ,new-val))) > > (define old-set! set!) > > (define-macro (set! a b) > `(if (procedure? ,a) ;; Needs a better check. > (,a ,b) > (old-set! ,a ,b))) > > > guile> (define x 10) > guile> (define y (location x)) > guile> (set! y 20) > guile> x > 20 > guile> I just realized that this is only a partial solution. Continuing the above example, guile> y # I don't know how to solve it: the problem is that you actually can't bind a function call to a variable. But even without it, the line (define old-set! set!) breaks: ERROR: invalid syntax set! I've been thinking of implementing this "location" stuff as a smob, but you've got the point that it is (probably) impossible to implement the location system without redefining set! and define. Regards M.