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: References/locations Date: Fri, 8 Aug 2008 03:50:33 +0200 Message-ID: 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 1218160257 31232 80.91.229.12 (8 Aug 2008 01:50:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 Aug 2008 01:50:57 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Aug 08 03:51:49 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 1KRH8s-0005P3-O8 for guile-user@m.gmane.org; Fri, 08 Aug 2008 03:51:47 +0200 Original-Received: from localhost ([127.0.0.1]:56021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KRH7v-0007BH-N3 for guile-user@m.gmane.org; Thu, 07 Aug 2008 21:50:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KRH7q-0007AI-D5 for guile-user@gnu.org; Thu, 07 Aug 2008 21:50:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KRH7o-000791-Et for guile-user@gnu.org; Thu, 07 Aug 2008 21:50:41 -0400 Original-Received: from [199.232.76.173] (port=39618 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KRH7o-00078n-9R for guile-user@gnu.org; Thu, 07 Aug 2008 21:50:40 -0400 Original-Received: from wf-out-1314.google.com ([209.85.200.171]:35599) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KRH7n-0002Gd-Ie for guile-user@gnu.org; Thu, 07 Aug 2008 21:50:40 -0400 Original-Received: by wf-out-1314.google.com with SMTP id 28so621862wfc.24 for ; Thu, 07 Aug 2008 18:50:33 -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:mime-version:content-type:content-transfer-encoding :content-disposition; bh=rPw3qlyN6sMmUzKZfhjpo45yZ3rIr3nfw6ES8Vw4c4c=; b=l3h9KmSImB6jqC2ZHoMotGrCKwhkSOGHmtlt1X7NF5kUYyVgeLnsxuAXB+PITDk+IF lIEvrDJNsL+msabX9ujnuh1d5r6EwGNUbopD9F2/dLrz+7w7NtDR2dR8rOy8cpUMw7sT Qr++HyTG580ZrM+sShk2p2DtRnj1EZ3msUotE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=GuRsQDvqTdUJFsk1vdLys+r6p0NVJZhxVKeJ0Gv71pQOEvIwOUdFD6rY98AE2DUqHz 7HJTcleaEQqFVqCL7lN1M+3SUEohsYWfeOwhWs9QFF+T6YaeHeUZPyJWUAZ2KqRx94vr azdv3pEtrcrAI5YExBMZtT/J732YW0qHcOTdI= Original-Received: by 10.142.245.6 with SMTP id s6mr727016wfh.187.1218160233472; Thu, 07 Aug 2008 18:50:33 -0700 (PDT) Original-Received: by 10.142.141.17 with HTTP; Thu, 7 Aug 2008 18:50:33 -0700 (PDT) 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:6729 Archived-At: Hi, it's me again, asking silly questions. This time I would like to know if there's a simple way to store a reference to a variable in another variable -- say, an element of vector or hash table. I imagine this could look like this: (define v #(1 2 3)) (define v1 (vector-location v 1)) v1 : 2 (set! v1 10) v : #(1 10 3) I've tried to do it using a "procedure with setter", but the problem is that set! doesn't evaluate its first argument (as long as it's a symbol), so I'd have to wrap everything up in macros to obtain: (set! (vector-location v 1) 10) Besides I think that the names "hash-ref" and "vector-ref" are confusing, since they don't return references, but values (therefore the names like "vector-get" or "hash-get" would be more apropreate) I also wonder if there's any point for allowing locations to any sorts of variables (similar to pointers in C or pointers to C++), that is, (define x 10) (define y (location x)) (set! y 20) x : 20 I expect that this idea isn't new in the world of lisp, but I didn't find any discussion on the web. There are certainly some issues related with locations: - they require special behavior of set! and define: (set! y 20) could work in two different ways, depending on whether y is a location or not - what about "locations of locations"? - how would it affect performance? - what about multiple threads? Regards M.