From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.lisp.guile.devel Subject: Re: Anything better for delayed lexical evaluation than (lambda () ...)? Date: Sun, 11 Dec 2011 10:33:50 +0100 Organization: Organization?!? Message-ID: <87d3bvfo5d.fsf@fencepost.gnu.org> References: <87liqtpsl9.fsf@fencepost.gnu.org> <874nxdwkbi.fsf@rapitore.luna> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1323596060 20484 80.91.229.12 (11 Dec 2011 09:34:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 11 Dec 2011 09:34:20 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Dec 11 10:34:16 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 1RZfnT-0008Bl-NE for guile-devel@m.gmane.org; Sun, 11 Dec 2011 10:34:15 +0100 Original-Received: from localhost ([::1]:32874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZfnT-0002jk-7j for guile-devel@m.gmane.org; Sun, 11 Dec 2011 04:34:15 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:43408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZfnR-0002jf-EC for guile-devel@gnu.org; Sun, 11 Dec 2011 04:34:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RZfnQ-0008Tw-1z for guile-devel@gnu.org; Sun, 11 Dec 2011 04:34:13 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:43915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZfnP-0008Th-Pd for guile-devel@gnu.org; Sun, 11 Dec 2011 04:34:12 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RZfnN-0008AU-PC for guile-devel@gnu.org; Sun, 11 Dec 2011 10:34:09 +0100 Original-Received: from p508eab30.dip.t-dialin.net ([80.142.171.48]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 11 Dec 2011 10:34:09 +0100 Original-Received: from dak by p508eab30.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 11 Dec 2011 10:34:09 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p508eab30.dip.t-dialin.net X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) Cancel-Lock: sha1:cCRE5wKZY8883ANh7Lsugga8sq8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 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:13034 Archived-At: Marco Maggi writes: > David Kastrup wrote: >> Hi, if I have something read that is evaluated later, the >> lack of procedure-environment in Guilev2 implies that I >> have to wrap the stuff in (lambda () ...) in order to >> capture the lexical environment for evaluation. > > Sorry to step in without an answer. What are you trying to > do? What I understand is that a Scheme program reads some > expressions and tries to evaluate them in a specific context > of the program. Are you looking for a way to do something > like the following chunk I found on the Net? > > (define x 0) > (define clo > (let ((x 1)) > (lambda () '()))) > (local-eval 'x (procedure-environment clo)) > => 1 It is more like (define (myeval what) (let* ((x 1) (clo (procedure-environment (lambda () #f)))) (local-eval (read (open-input-string what)) clo))) (myeval "(+ x 3)") Basically a string evaluation of a string that will be captured with read-hash-extend in our application. In practice, _both_ the environment created by (let* ((x 1)) ...) as well as the string to be interpreted later are written by the user, but they are spliced together at quite different points of time since the environment from which the string for myeval gets delivered is available only when the definition is being executed, not yet at its definition time. Basically I need to evaluate dynamic code in a given lexical environment rather than at top and/or module level. For a language that is supposed to be a building block for extension languages, not really a concept that is all that unusual I would think. -- David Kastrup