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: Wed, 14 Dec 2011 23:12:39 +0100 Organization: Organization?!? Message-ID: <87pqfq7qg8.fsf@fencepost.gnu.org> References: <87liqtpsl9.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> <87borboalb.fsf@netris.org> <87liqf5uty.fsf@pobox.com> <87vcpjmn3c.fsf@netris.org> <87fwgmn9w6.fsf@netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1323900787 15574 80.91.229.12 (14 Dec 2011 22:13:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 14 Dec 2011 22:13:07 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Dec 14 23:13:03 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 1Rax4P-0004F2-Gp for guile-devel@m.gmane.org; Wed, 14 Dec 2011 23:13:01 +0100 Original-Received: from localhost ([::1]:58011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rax4O-0004KE-RK for guile-devel@m.gmane.org; Wed, 14 Dec 2011 17:13:00 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:59249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rax4L-0004Jq-Gu for guile-devel@gnu.org; Wed, 14 Dec 2011 17:12:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rax4K-0004nC-Cg for guile-devel@gnu.org; Wed, 14 Dec 2011 17:12:57 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:36405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rax4J-0004n5-Ro for guile-devel@gnu.org; Wed, 14 Dec 2011 17:12:56 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Rax4I-0004BF-Fa for guile-devel@gnu.org; Wed, 14 Dec 2011 23:12:54 +0100 Original-Received: from p508ecc79.dip.t-dialin.net ([80.142.204.121]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 14 Dec 2011 23:12:54 +0100 Original-Received: from dak by p508ecc79.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 14 Dec 2011 23:12:54 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p508ecc79.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:vU83Jjkq6G22otVUuywgGELqqsI= 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:13105 Archived-At: Mark H Weaver writes: > Hi Noah, > > Noah Lavine writes: >> Perhaps this is obvious to everyone else, but it just occurred to me >> that (capture-local-environment) is just >> (call-with-current-continuation), but running in the environment of >> the evaluator instead of the program being evaluated. It's as though >> the evaluator was going to look in a tree for more code, but hit a >> special node and did a (call/cc). I hope other people find this >> interesting. > > Ah yes, that's an excellent point! (define (my-eval form env) (call-with-current-continuation (lambda (x) (env (list x form))))) (define-macro (my-env) (call-with-current-continuation identity)) (format #t "~a" (my-eval '(+ x 3) (let ((x 4)) (my-env)))) > In fact it makes me wonder whether `the-environment' and `local-eval' > could actually be implemented this way. I see some complications that > might make this strategy impractical or fragile, most notably that we > must be assured that the (call/cc) does not happen until > (the-environment) would have been _evaluated_, whereas the > expander/memoizer/evaluator will want to see what code is there _before_ > evaluation. I'll have to think about this. There might be an easy and > robust way to do this, or maybe not. Feel free to experiment with the above. I have my doubt that it leads to sane behavior. In particular, it will refinish macro expansion (so you don't want significant material behind it) and reevaluate the _whole_ eval it is in up to the point of calling my-env (so you don't want significant material before it). So it is more a joke than anything of practical value. But is _is_ good for a few dropjaws. -- David Kastrup