unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* syntax-locally-bound-identifiers, local-eval
@ 2012-01-20 12:33 Andy Wingo
  2012-01-20 12:42 ` Andy Wingo
  2012-01-22  0:28 ` Ludovic Courtès
  0 siblings, 2 replies; 8+ messages in thread
From: Andy Wingo @ 2012-01-20 12:33 UTC (permalink / raw)
  To: guile-devel

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/



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-25 23:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20 12:33 syntax-locally-bound-identifiers, local-eval Andy Wingo
2012-01-20 12:42 ` Andy Wingo
2012-01-20 19:04   ` Mark H Weaver
2012-01-20 20:00   ` Mark H Weaver
2012-01-22  7:01     ` Mark H Weaver
2012-01-23 12:52       ` Andy Wingo
2012-01-25 23:44         ` Andy Wingo
2012-01-22  0:28 ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).