Yes in that case this stands on it's own!
/Stefan

On Mon, Oct 22, 2012 at 9:11 PM, Mikael Djurfeldt <mik...@djurfeldt.com>wrote:

> On Mon, Oct 22, 2012 at 8:31 PM, Stefan Israelsson Tampe
> <stefan.ita...@gmail.com> wrote:
> >> Comments?  Can I add syntax-toplevel? to psyntax.scm and (system
> >> syntax)?
> > [...]
> > I can answer with some kind of suggestion here.
> >
> > in (system syntax) there is syntax-local-binding which you can use for
> > example as
> >
> >
> > (define-syntax f
> >   (lambda (x)
> >     (syntax-case x ()
> >       ((_ x)
> >         (call-with-values (lambda () (syntax-local-binding #'x))
> >                                 (lambda (x y) (pk x) (pk y))) #'#t))))
> >
> > Then,
> >
> > scheme@(guile-user) [1]> (f +)
> >
> > ;;; (global)
> >
> > ;;; ((+ guile-user))
> >
> > And,
> >
> > scheme@(guile-user) [1]> (let ((s 1)) (f s))
> >
> > ;;; (lexical)
> >
> > ;;; (s-490)
> >
> > (let ((s 1)) (define-syntax g (lambda (x) #'#f)) (f g))
> >
> > ;;; (displaced-lexical)
> >
> > ;;; (#f)
> >
> > I'm not sure what exactly syntax-toplevel? does, but can you base it on
> > syntax-local-binding?
> > And if not is it possible to change syntax-local-binding so that you can
> use
> > it?
>
> Thanks, Stefan.
>
> (syntax-toplevel?) expands to #t if occurs in a context (position in
> the code if you prefer) where a (define x #f) would create/set! a
> global binding for x.  It expands to #f otherwise.
>
> I had a look at syntax-local-binding, but decided that
> syntax-toplevel? was needed since the latter is not trying to
> determine the nature of an existing binding but rather the nature of
> the context.  Of course oncould probe the context by first creating a
> new binding (with some random name) and then use syntax-local-binding
> to determine the nature of the context by looking at the new binding,
> but that seems somewhat invasive. :-)
>

Reply via email to