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: Anything better for delayed lexical evaluation than (lambda () ...)? Date: Wed, 14 Dec 2011 02:50:56 -0500 Message-ID: <87borboalb.fsf@netris.org> References: <87liqtpsl9.fsf@fencepost.gnu.org> <874nxdwkbi.fsf@rapitore.luna> <87d3bvfo5d.fsf@fencepost.gnu.org> <871usaicvi.fsf@netris.org> <87mxaycmlx.fsf@fencepost.gnu.org> <87wra1hcek.fsf@netris.org> <87mxaxihnw.fsf@pobox.com> <87obvclu92.fsf@fencepost.gnu.org> <87aa6wbp0w.fsf@pobox.com> <87fwgolgm5.fsf@fencepost.gnu.org> <8762hkbkwi.fsf@pobox.com> <87borclcem.fsf@fencepost.gnu.org> <87zkewa2vy.fsf@pobox.com> <87zkewjvyz.fsf@fencepost.gnu.org> <87vcpka13n.fsf@pobox.com> <87zkewnzy7.fsf@netris.org> <87r5089ui3.fsf@pobox.com> <87r508nv0o.fsf@netris.org> <87fwgondme.fsf@netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1323849184 16732 80.91.229.12 (14 Dec 2011 07:53:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 14 Dec 2011 07:53:04 +0000 (UTC) Cc: Andy Wingo , David Kastrup , guile-devel@gnu.org To: Noah Lavine Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Dec 14 08:52:59 2011 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 1Raje7-000800-KN for guile-devel@m.gmane.org; Wed, 14 Dec 2011 08:52:59 +0100 Original-Received: from localhost ([::1]:44605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Raje7-0000cD-4D for guile-devel@m.gmane.org; Wed, 14 Dec 2011 02:52:59 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:58747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rajdz-0000c4-I8 for guile-devel@gnu.org; Wed, 14 Dec 2011 02:52:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rajdt-0004Ti-On for guile-devel@gnu.org; Wed, 14 Dec 2011 02:52:51 -0500 Original-Received: from world.peace.net ([96.39.62.75]:37950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rajdt-0004Se-Ll; Wed, 14 Dec 2011 02:52:45 -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 1Rajdd-0000hZ-Ta; Wed, 14 Dec 2011 02:52:30 -0500 In-Reply-To: <87fwgondme.fsf@netris.org> (Mark H. Weaver's message of "Tue, 13 Dec 2011 20:30:49 -0500") 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:13078 Archived-At: I have successfully implemented the (capture-lexical-environment) special form in the evaluator, and also primitive-local-eval. Here's a transcript from a test session: scheme@(guile-user)> (define env1 (primitive-eval '(let ((x 1) (y 2)) (capture-lexical-environment)))) scheme@(guile-user)> (primitive-local-eval 'x env1) $2 = 1 scheme@(guile-user)> (primitive-local-eval 'y env1) $3 = 2 scheme@(guile-user)> (primitive-local-eval '(set! x (+ x 10)) env1) $4 = 11 scheme@(guile-user)> (primitive-local-eval 'x env1) $5 = 11 scheme@(guile-user)> (define env2 (primitive-local-eval '(begin (set! x (+ x 1)) (let ((z 3)) (capture-lexical-environment))) env1)) scheme@(guile-user)> (primitive-local-eval 'z env2) $7 = 3 scheme@(guile-user)> (primitive-local-eval 'x env2) $8 = 12 scheme@(guile-user)> (primitive-local-eval 'y env2) $9 = 2 Note that in addition to the evaluator and memoizer environments, I also needed to add an expander environment to the overall lexical environment object. I will post a preliminary patch shortly. It's fairly small. Mark