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: summary: lilypond, lambda, and local-eval Date: Thu, 15 Dec 2011 18:24:16 +0100 Organization: Organization?!? Message-ID: <87bor9694v.fsf@fencepost.gnu.org> References: <87r506uodd.fsf@pobox.com> <9365BFAA-2F16-438E-A6B7-7C2AE4E48B08@telia.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1323969882 10145 80.91.229.12 (15 Dec 2011 17:24:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Dec 2011 17:24:42 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Dec 15 18:24:38 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 1RbF2s-0006HF-5o for guile-devel@m.gmane.org; Thu, 15 Dec 2011 18:24:38 +0100 Original-Received: from localhost ([::1]:41004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbF2r-0000tV-Jp for guile-devel@m.gmane.org; Thu, 15 Dec 2011 12:24:37 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbF2o-0000tO-LC for guile-devel@gnu.org; Thu, 15 Dec 2011 12:24:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbF2n-0002Xs-Bd for guile-devel@gnu.org; Thu, 15 Dec 2011 12:24:34 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:49290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbF2n-0002Xe-07 for guile-devel@gnu.org; Thu, 15 Dec 2011 12:24:33 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RbF2k-0006BN-Rl for guile-devel@gnu.org; Thu, 15 Dec 2011 18:24:30 +0100 Original-Received: from p508eb977.dip.t-dialin.net ([80.142.185.119]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Dec 2011 18:24:30 +0100 Original-Received: from dak by p508eb977.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Dec 2011 18:24:30 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 63 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p508eb977.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:6kxdCc1KKqWo/WMVWOY1xGIw8so= 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:13118 Archived-At: Hans Aberg writes: > On 15 Dec 2011, at 11:21, Andy Wingo wrote: > >> The "delayed evaluation" thread is a bit long and confusing, so I would >> like to try to summarize it. >> >> Lilypond has a way to embed Lilypond code in Scheme, and Scheme code in >> Lilypond code. The former uses a reader macro, #{#}. The latter uses >> specially-marked variables and expressions, specifically, those preceded >> by $ or #. > ... >> It took some time for everyone to understand the problem. In the end, >> there were four workable possibilities. >> >> 1) Keep using closures. > > When doing a parser on top of Guile, I noticed one must first build an > unevaluated closure, and only thereafter call the evaluator. Scheme > has some restrictions forcing this, for example, the lambda cannot > appear as a free symbol, though it is possible in Guile using > scm_sym_lambda. > > It might be useful with a variation of scm_eval_string() that only > parses and builds the closure, but not calls the evaluator. I am not sure what you mean with "closure" here, but just "read" parses a form. I was actually surprised playing around with the dirty call/cc hack I posted about just how many uses of my-eval and my-env appear to do what you would expect to in Guilev1: (define (my-eval form env) (call-with-current-continuation (lambda (x) (env (list x form))))) (define-macro (my-env) (call-with-current-continuation identity)) (define (xxx) (let* ((x 2)) (set! x (+ x 3)) (my-env))) (format #t "~a\n" (my-eval '(begin (set! x (+ x 5)) x) (xxx))) So far, just fooling around in the expectation that things will break has not succeeded. One probably should do a more analytic attempt of breakage. I have little doubt that using a compiler would make it much less likely to get working results, but haven't tried. Of course, exporting a half-finished evaluator is much less likely to work reliably and with tolerable amount of stored information than a properly exported environment would. -- David Kastrup