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: Closure? Date: Fri, 11 Jul 2008 22:54:35 +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 1215809699 23277 80.91.229.12 (11 Jul 2008 20:54:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Jul 2008 20:54:59 +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 Jul 11 22:55:45 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 1KHPeY-0007jC-Ok for guile-user@m.gmane.org; Fri, 11 Jul 2008 22:55:43 +0200 Original-Received: from localhost ([127.0.0.1]:44432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KHPdf-0004Pw-V5 for guile-user@m.gmane.org; Fri, 11 Jul 2008 16:54:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KHPda-0004Od-Qx for guile-user@gnu.org; Fri, 11 Jul 2008 16:54:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KHPdX-0004O4-FZ for guile-user@gnu.org; Fri, 11 Jul 2008 16:54:42 -0400 Original-Received: from [199.232.76.173] (port=36422 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KHPdX-0004O1-8e for guile-user@gnu.org; Fri, 11 Jul 2008 16:54:39 -0400 Original-Received: from an-out-0708.google.com ([209.85.132.251]:3173) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KHPdV-0004ZS-Vc for guile-user@gnu.org; Fri, 11 Jul 2008 16:54:38 -0400 Original-Received: by an-out-0708.google.com with SMTP id c38so732685ana.84 for ; Fri, 11 Jul 2008 13:54:35 -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=0HeTpiCJPc6TFeLV/wAeVzxHMgNz51Jd+3sHzV3/NUw=; b=X8NLut2CXRRCMnjT4aALA+9O7zl+WxZNhmzyrTNtHHxA5BQwa2p0hKg8ozJ2fqFlPf uIU1pgZ9vD4Yg+yfvjXMnvCAL9Up6nTmWYXXE6ZDk3Y25e8iFILjIl7kuGIrCTZBnAfd wigSpLk5gJeToSFfI2Muh3qHYb8fL9YLaYTvo= 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=Ptk1okUx+2CfzfcEQx8Fe87E/zn9R7CJXnLWTCl0pmZzS7gMbxT38mbcxWvvVDU627 XxHAz7Q1WYwTV1/UAU9m5q7/pLruzfOsUxOXIg+7BRzEhowl7IdGIrKWC2eC3SepKE7L 7tihcqAISbKUaTIVb4eaPVOqwFd+Segc02IGo= Original-Received: by 10.100.57.6 with SMTP id f6mr8944124ana.58.1215809675685; Fri, 11 Jul 2008 13:54:35 -0700 (PDT) Original-Received: by 10.100.44.13 with HTTP; Fri, 11 Jul 2008 13:54:35 -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:6644 Archived-At: Kjetil S. Matheussen: > The function "local-eval" is probably what you want. > > I use local-eval a lot, it's one of the really really > nice features provided by Guile: > > > (define-macro (with env . code) > `(local-eval (quote (begin ,@code)) ,env)) > > > (define ++ > (let ((c 0)) > (c-display "env" (the-environment)) > (lambda() > (set! c (1+ c)) c))) I don't actually get the line with c-display. Does it require any additional module? 'Cause it ain' workin' for me. (and besides what does it do? the remaining part works fine) > (++) > => 1 > (with (procedure-environment ++) (set! c 20)) > > (++) > => 20 I'm really impressed :) Great respect! I only wonder if there's a way to add a new variable to an existing closure, or to delete one. (not that I need it right now; but I imagine that it can be implemented quite easily and efficiently in C if the notion of closure is well-defined and explicit)