From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Julian Graham Newsgroups: gmane.lisp.guile.user Subject: Re: wrapping `define-syntax' Date: Mon, 13 Apr 2009 09:39:15 -0400 Message-ID: <2bc5f8210904130639o3d595ce6n62b006c50e880b5c@mail.gmail.com> References: <2bc5f8210904121555v1090cb8ej6602f72beefa2f20@mail.gmail.com> <8763h8rj58.fsf@arudy.ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1239630230 22954 80.91.229.12 (13 Apr 2009 13:43:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 13 Apr 2009 13:43:50 +0000 (UTC) Cc: Guile Users To: Neil Jerram Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Apr 13 15:45:09 2009 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LtMT5-0002KD-Uk for guile-user@m.gmane.org; Mon, 13 Apr 2009 15:45:00 +0200 Original-Received: from localhost ([127.0.0.1]:36733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LtMRh-0004c9-CU for guile-user@m.gmane.org; Mon, 13 Apr 2009 09:43:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LtMNj-000246-AO for guile-user@gnu.org; Mon, 13 Apr 2009 09:39:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LtMNd-00022V-0R for guile-user@gnu.org; Mon, 13 Apr 2009 09:39:25 -0400 Original-Received: from [199.232.76.173] (port=49486 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LtMNc-00022G-Mt for guile-user@gnu.org; Mon, 13 Apr 2009 09:39:20 -0400 Original-Received: from mail-qy0-f116.google.com ([209.85.221.116]:65527) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LtMNb-0000nz-MX for guile-user@gnu.org; Mon, 13 Apr 2009 09:39:19 -0400 Original-Received: by qyk14 with SMTP id 14so3257102qyk.14 for ; Mon, 13 Apr 2009 06:39:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=c6nP4ag8PBR8PknA5jsHogzk/H0zVhXT5FQhZvfO7pQ=; b=UqrYi0f+F3Q6UaUTrTRuJVhXaFfgD9XGBAUx/dNek0u6rrWUeb5t3Xir0PD3FO6fjO o9ZISEVABZY5WFSuyNvhv0aa599mW/JAVou8xzAKzMEDxDVppZQFmblR6puBhU+r2Ofn At2MfYk7cH9jvvHCIE/ICmdg+k4lZDJAYEggY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=UCvBoZlDCP0kqcTOkPxJ+3WBuNIQ2f5Ghl++EmszvSz/nsV2AdXZKG/6LN/K3Ge49G syJQGuvIcKBgjyY7p0rNn39/7uCHVojIdhpfnsJzmWJbTeukkvoLm4w3Z5tgbCEDpptn zh2IVWpYMOJasfeh8vCZO5ktLch2gkSvZmb6s= Original-Received: by 10.220.44.212 with SMTP id b20mr6156814vcf.116.1239629958865; Mon, 13 Apr 2009 06:39:18 -0700 (PDT) In-Reply-To: <8763h8rj58.fsf@arudy.ossau.uklinux.net> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7210 Archived-At: Hi Neil, >> For the purpose of some experiments I've been doing with integrating >> R6RS libraries, I've been trying to figure out ways to wrap >> `define-syntax' so that I can do things like add bindings to a >> module's eval closure before evaluating a macro definition. > > Can you give an example? Well, in R6RS, the body of `define-syntax' forms is evaluated in a higher "phase" -- meaning that there are additional bindings visible while it's being evaluated. I'm using a dynamically-created module as the evaluation environment, and I've grouped the phased bindings into modules that can be temporarily added to the dynamic module's "uses" list. So my custom `define-syntax' would look something like: (inject-modules-for-phase (current-module) (get-modules-for-phase current-phase)) (canonical-define-syntax keyw expr) (remove-injected-modules (current-module)) The rationale is that having the modules containing the phased bindings in the uses list will make them visible in the closures used by syncase -- which, with Andy's syncase hygiene changes in place, will lead to the module-relative `@' forms being produced in the expansion. (I had a naive version working earlier -- which I attached to a message to guile-devel -- that wasn't aware of lexical scope, and I'm trying to rewrite it to rely more on Guile's evaluator.) > Hmm. =A0I don't really have much idea... but given that define-syntax is > syntax, does (define-syntax canonical-define-syntax define-syntax) > work any better? Nope: ERROR: invalid syntax define-syntax > Also does it make any difference if you use use-syntax instead of > use-modules ? Nope, doesn't seem to have any effect. Regards, Julian