On May 2, 2016, at 9:10 AM, Sam Tobin-Hochstadt <sa...@cs.indiana.edu> wrote:
>
> No, `syntax-local-introduce` is not hygenic. It's basically "pretend
> that this identifier was in the input", which is fundamentally
> unhygenic.
Sorry to be dense, but I still don't see the "pretend that this identifier was
in the input" angle. Below, example 1 fails with an unbound-identifier error,
because the `syntax-local-introduce` identifier does not capture the use-site
reference. Whereas example 2 works, even though the `invoke-x` macro ostensibly
uses a hygienic reference.
Having looked at the scope sets, I now understand WHY the behavior below
happens. But `syntax-local-introduce` clearly does something quite different
from, say, `(datum->syntax caller-stx datum)` (whose behavior I think of as
"pretend that this identifier was in the input").
;;;;;;;;;;;;;;;
#lang racket
(require rackunit)
(module macros racket
(provide (all-defined-out))
(define-syntax (sli-x stx)
(syntax-case stx ()
[(_) (with-syntax ([x (syntax-local-introduce #'x)])
#'(define x 'syntax-local-introduce-x))]))
(define-syntax-rule (invoke-x) x))
(require 'macros)
;; example 1
(check-equal?
(let ()
(sli-x)
x) 'syntax-local-introduce-x)
;; example 2
(check-equal?
(let ()
(sli-x)
(invoke-x)) 'syntax-local-introduce-x)
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.