Progress is a new error! I don't think I understand how syntax-local-bind-syntaxes is supposed to work. I extended the previous program:<br><br><div>#lang racket</div><div>(require (for-syntax syntax/parse))</div><div>(define-syntax (test stx)</div><div>  (syntax-parse stx</div><div>    [(_ e)</div><div>     (define ctx </div><div>       (if (list? (syntax-local-context))</div><div>           (cons (gensym) (syntax-local-context))</div><div>           (list (gensym))))</div><div>     (define def-ctx (syntax-local-make-definition-context))</div><div>     (define expd (local-expand #'e ctx (list #'define-values) def-ctx))</div><div>     (define ids (syntax-parse expd [(def (id) _) (list #'id)]))</div><div>     (syntax-local-bind-syntaxes ids #f def-ctx)</div><div>     (internal-definition-context-seal def-ctx)</div><div>     expd]))</div><div>(let ()</div><div>  (test (define x 1))</div><div>  x)<br><br>And now I receive the error:  `x: unbound identifier in module in: x`<br>Looking at the docs for `syntax-local-make-definition-context` it seems like I need to provide it with the parent definition-context, but I'm not sure how to get a hold of that.<br><br>--spf</div><br><div class="gmail_quote">On Mon Jan 05 2015 at 10:00:53 AM Matthew Flatt <<a href="mailto:mflatt@cs.utah.edu" target="_blank">mflatt@cs.utah.edu</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The error message is intended for "end users" and turns out to be<br>
misleading for the implementor of an internal-definition context. The<br>
documentation for `define-values` has essentially the same problem: it<br>
describes how `define-values` should work in an internal-definition<br>
context, but it doesn't say how the form interacts with `local-expand`.<br>
<br>
A `define-values` form will only expand in a module or top-level<br>
context. To implement an internal-definition context, you must expand<br>
only far enough to see `define-values` form; in other words, supply<br>
`#'define-values` in the stop list. Then, a partially expanded<br>
`define-values` form must be recognized and handled explicitly, with<br>
tools like `syntax-local-bind-syntaxes` or re-writing to<br>
`letrec-values`, as appropriate for the definition context.<br>
<br>
At Mon, 05 Jan 2015 14:49:03 +0000, Spencer Florence wrote:<br>
> Hey all,<br>
><br>
> I'm trying to use 'local-expand', however it seems to think its never in a<br>
> definition context. For example:<br>
><br>
> (require (for-syntax syntax/parse))<br>
> (define-syntax (test stx)<br>
>   (syntax-parse stx<br>
>     [(_ e)<br>
>      (define ctx<br>
>        (if (list? (syntax-local-context))<br>
>            (cons (gensym) (syntax-local-context))<br>
>            (list (gensym))))<br>
>      (local-expand<br>
>       #'e ctx null<br>
>       ;; result is the same with this uncommented<br>
>       #;(syntax-local-make-<u></u>definiti<u></u>on-context))]))<br>
> (let ()<br>
>   (test (define x 1))<br>
>   x)<br>
><br>
> errors with a "define-values: not in a definition context in:<br>
> (define-values (x) 1)"<br>
><br>
> Can anyone provide any insight into what is going on?<br>
><br>
> --spf<br>
> ____________________<br>
>   Racket Users list:<br>
>   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u><u></u>users</a><br>
</blockquote></div>