> On May 2, 2016, at 11:50 AM, Sam Tobin-Hochstadt <[email protected]> wrote:
>> 
>> My initial statement was less precise than my second email.
>> `(syntax-local-introduce stx)` adds a single scope, using the
>> equivalent of `'flip` mode. That scope is "the current scope" for the
>> macro expansion step.

I appreciate your more detailed explanation. 

The common thread in the Knauth/Butterick critique is that 
`syntax-local-introduce` promises a result — syntax, locally introduced — but 
in fact delivers a certain action — adding a scope — that will only achieve the 
promised result if a certain other criterion is met (namely, a context-free 
syntax object). This is not apparent from the docs (though I will prepare a 
pull request to make it so).

Even with this clarification, some puzzling behavior awaits. For instance, you 
are correct that using `(datum->syntax #f 'x)` makes my two original examples 
work. But consider example #3 — where a subsequent local definition will shadow 
the `syntax-local-introduce` identifier, without an error — and example #4, 
which reverses the order of the two binding expressions, which then triggers an 
ambiguous-binding error.

;;;;

#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 (datum->syntax #f '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)

;; example 3: local definition shadows `syntax-local-introduce` but ...
(check-equal?
 (let ()
   (sli-x)
   (define x 'locally-defined)
   x) 'locally-defined)

;; example 4 ... if the two are reordered, you get an ambiguous-binding error
#;(check-equal?
 (let ()
   (define x 'locally-defined)
   (sli-x)
   x) 'locally-defined)


-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to