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: syntax-locally-bound-identifiers, local-eval Date: Fri, 20 Jan 2012 13:33:29 +0100 Message-ID: <87vco6tuxy.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 1327063234 12336 80.91.229.12 (20 Jan 2012 12:40:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 20 Jan 2012 12:40:34 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jan 20 13:40:27 2012 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 1RoDlX-000693-Ay for guile-devel@m.gmane.org; Fri, 20 Jan 2012 13:40:23 +0100 Original-Received: from localhost ([::1]:38489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoDlV-0007AC-TD for guile-devel@m.gmane.org; Fri, 20 Jan 2012 07:40:21 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:50334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoDlP-0007A6-0m for guile-devel@gnu.org; Fri, 20 Jan 2012 07:40:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RoDlK-000771-DD for guile-devel@gnu.org; Fri, 20 Jan 2012 07:40:14 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:55075 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoDlK-00076t-Ae for guile-devel@gnu.org; Fri, 20 Jan 2012 07:40:10 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 302087025 for ; Fri, 20 Jan 2012 07:40:09 -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=X mFQpRiqsoPuGODjEVm0o3u8kzs=; b=BVohfqkvrv9WAOAQtNU1Dw/qi2aysoc8H JuY4x8IyC1Lh0tNDbfXIy8WR1xczNBPR8gq75lTuTp88rhUuz1bApIZxLcK2eiwp qK2SuL9Ft8+S1tJqRJ/7c1lWAVgo/JYC5kfoJAj1YTkd/qeQ68dTZMYWtK11yOjr sHy3EX1OjI= 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=ax8 bcD7AAY1m3NESjICzBohHFbuVEjqUytZxcXuyvcoW9q7QAjUqP0bPlhNw7HdYoAD UYebTU4EQGwnh40b99+4TQmsVJwUqox8Fz9dhTEk9dm4GsS4uSnEL3wVRi4vs0+y ETfI31AenRWFpzeuFa45Zjj0R+tCk4KHhxnitG4o= 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 29E2D7024 for ; Fri, 20 Jan 2012 07:40:09 -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 E0B927023 for ; Fri, 20 Jan 2012 07:40:07 -0500 (EST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: E29E4550-4363-11E1-866A-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:13595 Archived-At: Hello, Here are a couple of patches. The first implements a new helper, syntax-locally-bound-identifiers, documented thusly: -- Scheme Procedure: syntax-locally-bound-identifiers id Return a list of identifiers that were visible lexically when the identifier ID was created, in order from outermost to innermost. This procedure is intended to be used in specialized procedural macros, to provide a macro with the set of bound identifiers that the macro can reference. As a technical implementation detail, the identifiers returned by `syntax-locally-bound-identifiers' will be anti-marked, like the syntax object that is given as input to a macro. This is to signal to the macro expander that these bindings were present in the original source, and do not need to be hygienically renamed, as would be the case with other introduced identifiers. See the discussion of hygiene in section 12.1 of the R6RS, for more information on marks. (define-syntax lexicals (lambda (x) (syntax-case x () ((lexicals) #'(lexicals lexicals)) ((lexicals scope) (with-syntax (((id ...) (filter (lambda (x) (eq? (syntax-local-binding x) 'lexical)) (syntax-locally-bound-identifiers #'scope)))) #'(list (cons 'id id) ...)))))) (let* ((x 10) (x 20)) (lexicals)) => ((x . 10) (x . 20)) The second implements local-eval, in a separate module. There are a couple of notable changes in this version: firstly, it correctly preserves the scope resolution order of scopes between normal lexicals, macros, and pattern variables. It includes all of the original marks of all identifiers. It also wraps pattern variables now, and doesn't re-box normal lexicals. Thoughts? I will commit them tomorrow if there are no objections to the semantics. Thanks very much to Mark for his great work on the patches that inspired these ones, even though he might wish to disavow this particular implementation strategy :-) Regards, Andy -- http://wingolog.org/