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: Tue, 13 Dec 2011 17:24:41 +0100 Message-ID: <87vcpkjv7a.fsf@fencepost.gnu.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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1323793501 27996 80.91.229.12 (13 Dec 2011 16:25:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 13 Dec 2011 16:25:01 +0000 (UTC) Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Dec 13 17:24:56 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 1RaV9x-0002oK-9f for guile-devel@m.gmane.org; Tue, 13 Dec 2011 17:24:53 +0100 Original-Received: from localhost ([::1]:33985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaV9w-0002NO-SF for guile-devel@m.gmane.org; Tue, 13 Dec 2011 11:24:52 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaV9o-0002F8-W1 for guile-devel@gnu.org; Tue, 13 Dec 2011 11:24:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaV9n-0001mE-88 for guile-devel@gnu.org; Tue, 13 Dec 2011 11:24:44 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]:47821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaV9n-0001m9-31 for guile-devel@gnu.org; Tue, 13 Dec 2011 11:24:43 -0500 Original-Received: from localhost ([127.0.0.1]:57742 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaV9m-0003w0-Hq; Tue, 13 Dec 2011 11:24:42 -0500 Original-Received: by lola (Postfix, from userid 1000) id EB7D2E5F55; Tue, 13 Dec 2011 17:24:41 +0100 (CET) In-Reply-To: <87zkewa2vy.fsf@pobox.com> (Andy Wingo's message of "Tue, 13 Dec 2011 16:48:49 +0100") 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: 140.186.70.10 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:13060 Archived-At: Andy Wingo writes: > On Tue 13 Dec 2011 16:27, David Kastrup writes: > >>> It sounds like `current-bindings' is the thing you need. >> >> It will at least be a year before any solution that does not work with >> Guile 1.8 will be accepted into Lilypond. > > It is possible to have similar interfaces with different > implementations, using `cond-expand'. lily.scm does this in one case, > implementing 2.0 interfaces on 1.8. > > I'll take a look at implementing something like this. > > To summarize your issue: you have code like: > > (lambda (a b c) > #{ here I have custom code that references lexical variables; > should it be able to set them too? }#) > > It would be relatively easy to pass in an alist of the lexicals, for > reference purposes; but do you want to be able to set them too, from > within that EDSL? It would appear that program-bindings on an anonymous lambda function that just creates a list of all # and $ scraps in #{ ... #} would deliver that. Then one needs to correlate every structure recursively with the resulting list of bindings, and create an anonymous lambda whenever the intersection is non-empty. It's doable, but its likely easier to just don't bother sorting out the non-environment depending functions from those that do. I should hope that storing and referencing near-trivial lambda functions should not be all too expensive in Guile v2. So without something approaching the comparative seamlessness of the procedure-environment/local-eval pairing, it is not likely that the effort would be warranted. The code currently in Lilypond is working well enough: as I said, I can work with any size of crowbar. And there would be little point to exchange the current hack for a differently tailored and likely more complex hack that is not a part of Guile proper and thus has an even smaller expected live span than the current solution. -- David Kastrup