From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: summary: lilypond, lambda, and local-eval Date: Thu, 15 Dec 2011 11:21:18 +0100 Message-ID: <87r506uodd.fsf@pobox.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1323944506 10266 80.91.229.12 (15 Dec 2011 10:21:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Dec 2011 10:21:46 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Dec 15 11:21:42 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 1Rb8RY-0005PD-2H for guile-devel@m.gmane.org; Thu, 15 Dec 2011 11:21:40 +0100 Original-Received: from localhost ([::1]:43028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8RX-0004WN-7T for guile-devel@m.gmane.org; Thu, 15 Dec 2011 05:21:39 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:41430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8RP-0004TU-Dc for guile-devel@gnu.org; Thu, 15 Dec 2011 05:21:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rb8RJ-0004vM-Cs for guile-devel@gnu.org; Thu, 15 Dec 2011 05:21:31 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:46171 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb8RJ-0004v9-6l for guile-devel@gnu.org; Thu, 15 Dec 2011 05:21:25 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 86CE17973 for ; Thu, 15 Dec 2011 05:21:24 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:mime-version:content-type; s=sasl; bh=0 N7oQU2VNI8QJZqxS0mMmTuYg4A=; b=i4OX5hVSImPUQBeatLnQroHMJMKUUY53U FdWoabdRHhbD+bGZuGAufc+VFmxtYCVPPt6H4aYu0OorlIoSo5bqmlGGelBY4mFH 6N9uQbwGM1DAyIWtQHVkmHSlVgwuF4fLjFeN+NsW6Lt0CTScxrccynhNrI/ab4jS Cqh25IsOiI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :date:message-id:mime-version:content-type; q=dns; s=sasl; b=QiZ vzbtBCMEBlWj4Q3Xut8ZdWmkNjz43s1slKfeGygdnFMBxURTHVGaVHA/434RXIBb B6LCVrf096MTu6prTfh4XRy/RntDIF8Zyu5upTXxz4f5rHTGMpEK/tKHc46U12OO 9oUIn5VGlu55reHrJ769ujIfsWkhzLkcpyjg4x4A= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 7ECD77972 for ; Thu, 15 Dec 2011 05:21:24 -0500 (EST) Original-Received: from badger (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 91DD57971 for ; Thu, 15 Dec 2011 05:21:22 -0500 (EST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: 897F8DB8-2706-11E1-B19C-65B1DE995924-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 74.115.168.62 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:13110 Archived-At: Hi, 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 #. For example, the following Scheme expression is an embedded lilypond code fragment: #{ \displayLilyMusic $p #} which expands out at read-time to: (# parser " \\displayLilyMusic $p " #f 0 (list (cons 20 (lambda () p)))) Here the procedure is embedded in the output of the reader macro. We can see that the $p is translated to (cons 20 (lambda () p)). Whenever $p is evaluated, that lambda is run. Embedded Scheme (via $ or #) has access to Scheme's environment. Variables in lilypond are in a separate environment (implemented using modules), so we don't have to be concerned about lilypond accessing or defining Scheme lexicals. David hacks on Lilypond. He notes that the above expression used to expand out to: (# parser " \\displayLilyMusic $p " #f 0 (the-environment)) in 1.8. Then, whenever lilypond needed to evaluate an embedded Scheme value, it would use `local-eval' with the captured environment. It is clearly much more convenient for lilypond hackers than having to scan for embedded Scheme beforehand and build up closures for each embedded Scheme expression. David noted that while "the closure solution" works for him, he wondered if there was something better to use. It took some time for everyone to understand the problem. In the end, there were four workable possibilities. 1) Keep using closures. 2) Incorporate local-eval and the-environment into Guile 2.0. 3) Have lilypond use its own evaluator or compiler. 4) Have lilypond make the embedded lilypond code expand out to actual Scheme. (It was unclear whether the lilypond grammar allowed this.) Mark and Noah looked at implementing local-eval, and I recommended staying with the closure solution. Ludovic noted success with method (3) in the Skribilo context. I would like to start a new thread around local-eval, but besides that, we should probably agree on the summary first. So please do send any corrections to this summary to the list. Thanks :) Andy -- http://wingolog.org/