<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>I just tried replacing the lexical context of path, and got this:</div><div><br></div><div><div>#lang racket/load</div><div>;;provider</div><div>(module T racket</div><div> (provide a)</div><div> (define a 1))</div><div>;; requirer</div><div>(module R racket</div><div> (require (for-syntax syntax/parse syntax/strip-context))</div><div> (define-syntax (test-binding stx)</div><div> (syntax-parse stx</div><div> [(_ path)</div><div> #:with new-path (replace-context #'here #'path)</div><div> #'(let () (local-require (only-in new-path a)) a)]))</div><div> (test-binding 'T))</div><div>;; go</div><div>(require 'R)</div></div><div><br></div><div>So I think when it expands (only-in path [a a]), it introduces a with the lexical context of the second a,</div><div>bit when it expands (only-in path a), it introduces a with the lexical context of path. </div><br><div><div>On Nov 6, 2014, at 4:36 PM, Spencer Florence <<a href="mailto:spencer@florence.io">spencer@florence.io</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Thanks! That fixed it!<br><br>Although I'm still curious as to why the error happens in the first place.<br><div class="gmail_quote">On Thu Nov 06 2014 at 3:32:02 PM Alexander D. Knauth <<a href="mailto:alexander@knauth.org">alexander@knauth.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think I had a similar sort of problem about a year ago (I was at either RacketCon or a Hackathon that same weekend and Mathew Flatt figured it out), and the solution was changing (only-in path a) to (only-in path [a a]).<br>
<br>
#lang racket/load<br>
;;provider<br>
(module T racket<br>
(provide a)<br>
(define a 1))<br>
;; requirer<br>
(module R racket<br>
(require (for-syntax syntax/parse))<br>
(define-syntax (test-binding stx)<br>
(syntax-parse stx<br>
[(_ path)<br>
#'(let () (local-require (only-in path [a a])) a)]))<br>
(test-binding 'T))<br>
;; go<br>
(require ‘R)<br>
<br>
<br>
On Nov 6, 2014, at 4:09 PM, Spencer Florence <<a href="mailto:spencer@florence.io" target="_blank">spencer@florence.io</a>> wrote:<br>
<br>
> Hi All,<br>
><br>
> I've been struggling to have a macro be given a path then require something from that path. The following code produces and "Unbound Identifier" error, although I would expect it to evaluate to 1. Could someone provide insight into what is going on?<br>
><br>
> #lang racket/load<br>
> ;;provider<br>
> (module T racket<br>
> (provide a)<br>
> (define a 1))<br>
> ;; requirer<br>
> (module R racket<br>
> (require (for-syntax syntax/parse))<br>
> (define-syntax (test-binding stx)<br>
> (syntax-parse stx<br>
> [(_ path)<br>
> #'(let () (local-require (only-in path a)) a)]))<br>
> (test-binding 'T))<br>
> ;; go<br>
> (require 'R)<br>
><br>
><br>
> P.S. I attempted to do this with `dynamic-require,` but that failed because in my actual program `path` is sometimes `(submod "..")`, which caused an error about not having a base path.<br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u>users</a><br>
<br>
</blockquote></div>
</blockquote></div><br></body></html>