unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* syntax-local-binding
@ 2012-01-15 17:00 Andy Wingo
  2012-01-15 17:22 ` syntax-local-binding Andy Wingo
  0 siblings, 1 reply; 27+ messages in thread
From: Andy Wingo @ 2012-01-15 17:00 UTC (permalink / raw)
  To: guile-devel

Hi list,

Attached is a patch that implements a new accessor,
syntax-local-binding.  It's like syntax-local-value, but can also
determine if an identifier is a pattern var or a normal lexical.

  > (define-syntax local-binding
      (lambda (x)
        (syntax-case x ()
          ((_ id) (identifier? #'id)
           (call-with-values (lambda () (syntax-local-binding #'id))
             (lambda (x y)
               (with-syntax ((type (datum->syntax #'here x)))
                 #''type)))))))
  > (let-syntax ((x (lambda (x) 10))) (local-binding x))
  $3 = local-macro
  > (syntax-case #'(foo) () ((id) (local-binding id)))
  $4 = pattern-variable
  > (let ((x 10)) (local-binding x))
  $5 = lexical

It returns two values.  The first is a symbol, either `local-macro',
`lexical', or `pattern-variable'.  The second is specific to the type.
For local-macro it is the transformer binding.  For lexical it is the
gensym name of the lexical.  For pattern variables, it is something
opaque that identifies that pattern var.

Inspired by a patch by Stefan Israelsson Tampe.

I'm going to try to implement the-environment with this.  We'll see how
it goes!

Andy
-- 
http://wingolog.org/



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

end of thread, other threads:[~2012-01-26 11:21 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-15 17:00 syntax-local-binding Andy Wingo
2012-01-15 17:22 ` syntax-local-binding Andy Wingo
2012-01-19 11:41   ` syntax-local-binding Andy Wingo
2012-01-20 20:26     ` syntax-local-binding Mark H Weaver
2012-01-20 21:23       ` syntax-local-binding Andy Wingo
2012-01-20 22:03         ` syntax-local-binding Mark H Weaver
2012-01-22  0:03           ` syntax-local-binding Ludovic Courtès
2012-01-23 16:05           ` syntax-local-binding Andy Wingo
2012-01-23 21:03             ` syntax-local-binding Mark H Weaver
2012-01-23 22:19               ` syntax-local-binding Andy Wingo
2012-01-24  2:11                 ` syntax-local-binding Mark H Weaver
2012-01-24 11:42                   ` syntax-local-binding Andy Wingo
2012-01-24 17:29                     ` syntax-local-binding Noah Lavine
2012-01-24 10:30                 ` syntax-local-binding Peter TB Brett
2012-01-24 10:38                   ` syntax-local-binding David Kastrup
2012-01-24 11:26                   ` syntax-local-binding Andy Wingo
2012-01-24 13:25                     ` syntax-local-binding Mark H Weaver
2012-01-24 20:28                       ` mark uniqueness (Was: Re: syntax-local-binding) Andy Wingo
2012-01-25  0:26                         ` mark uniqueness Mark H Weaver
2012-01-25  9:02                           ` Andy Wingo
2012-01-24 21:22                       ` syntax-local-binding Andy Wingo
2012-01-25  2:30                         ` syntax-local-binding Mark H Weaver
2012-01-25  7:49                           ` syntax-local-binding Stefan Israelsson Tampe
2012-01-25 11:18                           ` syntax-local-binding Andy Wingo
2012-01-25 13:18                           ` syntax-local-binding Ludovic Courtès
2012-01-25 18:08                             ` syntax-local-binding Mark H Weaver
2012-01-26 11:21                             ` syntax-local-binding Andy Wingo

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).