[racket-dev] internal-definition-context-seal doesn't seem to do anything

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Aug 16 01:32:25 EDT 2014

If you put the code below in a module, you don't get an error, because
the syntax object that has the unsealed context doesn't appear in the
fully-expanded module. The syntax object is in a local macro binding
that disappears.

If you remove the `let' around

  (bind h (define q 5))
  (define q 8)
  (nab h)

then the relevant syntax object remains in the fully expanded result,
and you get an error.

At Fri, 15 Aug 2014 14:33:35 -0400, Stephen Chang wrote:
> The docs say that if I make an internal definition context with
> syntax-local-make-definition-context, I have to seal it with
> internal-definition-context-seal, otherwise an exception gets raised.
> But I can't get this to happen. Does someone have an example that
> causes the exception to get thrown?
> 
> For example, this program from the racket tests produces the same
> result if I comment out the seal line. Other tests behave similarly.
> 
> (define-syntax (bind stx)
>   (syntax-case stx ()
>     [(_ handle def)
>      (let ([def-ctx (syntax-local-make-definition-context)]
>            [ctx (cons (gensym 'intdef)
>                       (let ([orig-ctx (syntax-local-context)])
>                         (if (pair? orig-ctx)
>                             orig-ctx
>                             null)))]
>            [kernel-forms (list #'define-values)])
>        (let ([def (local-expand #'def ctx kernel-forms def-ctx)])
>          (syntax-case def ()
>            [(define-values (id) rhs)
>             (begin
>               (syntax-local-bind-syntaxes (list #'id) #f def-ctx)
>               (internal-definition-context-seal def-ctx)
>               #'(begin
>                   (define-values (id) rhs)
>                   (define-syntax handle (quote-syntax id))))]
>            [_ (error "no")])))]))
> 
> (define-syntax (nab stx)
>   (syntax-case stx ()
>     [(_ handle)
>      (syntax-local-value #'handle)]))
> 
> (let ()
>   (bind h (define q 5))
>   (define q 8)
>   (nab h))
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.