[plt-scheme] [scribble] syntax quasi/unquote

From: Eric Tanter (etanter at dcc.uchile.cl)
Date: Thu Apr 29 14:05:44 EDT 2010

> I thought that something like this might work
> 
> (define-syntax-rule @INTERACTION[form ...]
>   @interaction[(eval:alts @#,SCHEMEBLOCK[form] form) ...])
> 
> but the problem is that the first part o `eval:lats' must be an
> element, instead of a block.
> 
> So, here's a different idea. The `def+int', etc. forms recognize
> `unsyntax' by its binding, so you can just shadow that binding, like
> this:
> 
> @(let ([unsyntax 'hide]) 
>    @def+int[
>     (define l 
>      #`(#,(+ 1 2)))
>     #`(#,l)
>    ])

it does not work with a macro, for instance

#lang scheme
(define-syntax FOO
  (lambda (stx)
    (syntax-case stx ()
      ((FOO val)
       #`(+ 1 #,(+ 1 2))))))
(FOO 2) 
--> 4

and:

@(let ([unsyntax 'hide]) 
 @def+int[
(define-syntax FOO
  (lambda (stx)
    (syntax-case stx ()
      ((FOO val)
       #`(+ 1 #,(+ 1 2))))))
(FOO 2) ])

gives 
eval:1:0: compile: unbound identifier in the transformer environment (and no #%app syntax transformer is bound) at: lambda in: (lambda (stx) (syntax-case stx () ((FOO val) (quasisyntax (+ 1 (unsyntax (+ 1 2)))))))

 === context ===
/Applications/_Extra/Devel/PLT Scheme v4.2.5/collects/scheme/private/more-scheme.ss:158:2: call-with-break-parameterization
/Applications/_Extra/Devel/PLT Scheme v4.2.5/collects/scheme/sandbox.ss:700:9: loop

I get the same error if I shadow both unsyntax and quasisyntax.

(side question: why having chosen the same escape characters for the @... than the ones for syntax objects?)

Thanks,

-- Éric

Posted on the users mailing list.