From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Neil Jerram" Newsgroups: gmane.lisp.guile.user Subject: Re: Closure? Date: Sat, 12 Jul 2008 23:57:24 +0100 Message-ID: <49dd78620807121557n5c7a1f3bs5a2c2788faca21a7@mail.gmail.com> 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 1215903475 2741 80.91.229.12 (12 Jul 2008 22:57:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Jul 2008 22:57:55 +0000 (UTC) Cc: guile-user@gnu.org To: "Maciek Godek" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jul 13 00:58:42 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 1KHo38-0006Ks-0U for guile-user@m.gmane.org; Sun, 13 Jul 2008 00:58:42 +0200 Original-Received: from localhost ([127.0.0.1]:56144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KHo2G-00060l-7q for guile-user@m.gmane.org; Sat, 12 Jul 2008 18:57:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KHo1v-0005se-No for guile-user@gnu.org; Sat, 12 Jul 2008 18:57:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KHo1u-0005rw-1p for guile-user@gnu.org; Sat, 12 Jul 2008 18:57:27 -0400 Original-Received: from [199.232.76.173] (port=34226 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KHo1t-0005rq-PC for guile-user@gnu.org; Sat, 12 Jul 2008 18:57:25 -0400 Original-Received: from rv-out-0708.google.com ([209.85.198.240]:11803) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KHo1t-0000Ez-DS for guile-user@gnu.org; Sat, 12 Jul 2008 18:57:25 -0400 Original-Received: by rv-out-0708.google.com with SMTP id k29so4917645rvb.6 for ; Sat, 12 Jul 2008 15:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.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=C7auSndbjqwOfQFt1rn5C91uNbUBu79bKK7V9tuQ6Iw=; b=XEaq68eJHYjgn0vJrg/9HTvnZtZp1j8c09Uw3vC4+lRJjVSyO/d3l9YB525IvK68K5 hgHp3TLpS8qH+pOVNRjy9q2akqYQJnLQZVc5faa3LJO5ko6qNFrsCnSUb2YAzsIlp1Q7 9xyW0SlGdTYyvXKg64JKPnFFh8+KhFtB2Yr18= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.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=nCe1fX1Gz9RuyzmJ+Wj2erAHzOYTlyzGu6rsVba4fmro0yUn73CeGFGCiQeIaU+XyB lx28YD9IdA2mv3p0thLUdKSzb2xmumSByMcrPLbsfmAaDTDmP9so/UW83S20DtBdAG8y syvaQDiWHV4CqxQamLLzc/S98RE4flL/0OKCg= Original-Received: by 10.115.76.5 with SMTP id d5mr15868789wal.191.1215903444071; Sat, 12 Jul 2008 15:57:24 -0700 (PDT) Original-Received: by 10.114.197.8 with HTTP; Sat, 12 Jul 2008 15:57:24 -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:6648 Archived-At: Hi Maciek, Just picking up another point from your original email. You may have already worked this out, but just in case... 2008/7/11 Maciek Godek : > > Additionaly, it would be nice to see the possibility > of explicit definitions of environments, like: > > (define env (make-closure (a . 1)(b . 2)) > (with env (define c 3)) This is equivalent to: (define env (let ((a 1) (b 2)) (the-environment))) (local-eval '(define c 3) env) except that the last line fails with a "Bad define placement" error. That's because there are special rules for defines inside lexical scopes. > so that we could define the aforementioned > counter as: > (define counter-env (make-closure (c . 0))) > (define ++ (with counter-env (lambda()(set! c (1+ c))c))) This one really works: (define counter-env (let ((c 0)) (the-environment))) (define (++) (local-eval '(begin (set! c (+ c 1)) c) counter-env)) So, in summary, make-closure wouldn't provide anything more than what we already have. Regards, Neil