<p dir="ltr">You should keep the original require and provide, and add the new inserted require as an extra. Does that work?</p>
<p dir="ltr">Sam</p>
<div class="gmail_quote">On Oct 17, 2014 6:38 AM, "Konrad Hinsen" <<a href="mailto:konrad.hinsen@fastmail.net">konrad.hinsen@fastmail.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sam Tobin-Hochstadt writes:<br>
<br>
> My suggestion is to have your `test-lang` language use<br>
> `#%module-begin` to expand into `(tr:module-begin (require<br>
> test-lang/more) user-program-here ...)`, which should fix the problem.<br>
<br>
Thanks, that sounds like a good idea... but it doesn't work either. Here's<br>
my new test-lang/main.rkt:<br>
<br>
-- test-lang/main.rkt ----------------------------<br>
#lang typed-racket/minimal<br>
<br>
(require typed/racket<br>
(only-in typed/racket<br>
[#%module-begin tr:module-begin]<br>
[require tr:require]))<br>
<br>
(provide (except-out (all-from-out typed/racket) #%module-begin)<br>
(rename-out [module-begin #%module-begin]))<br>
<br>
(define-syntax module-begin<br>
(syntax-rules ()<br>
[(_ decl ...)<br>
(tr:module-begin<br>
(tr:require test-lang/more)<br>
decl ...)]))<br>
--------------------------------------------------<br>
<br>
When I run my test program again:<br>
<br>
-- test.rkt --------------------------------------<br>
#lang test-lang<br>
<br>
(: x Integer)<br>
(define x 42)<br>
(print x)<br>
<br>
(print (bar x))<br>
--------------------------------------------------<br>
<br>
I get the error message<br>
<br>
; /Users/hinsen/projects/racket/test.rkt:9:8: bar: unbound identifier in module<br>
; in: bar<br>
<br>
When I remove the require from begin-module and put it right into test.rkt,<br>
it works just fine.<br>
<br>
I ran both versions through the macro stepper to see where the<br>
difference comes from. There is a difference right from the start,<br>
before any macro expansion is done: In the working version (with the<br>
require in test.rkt), the binding for 'bar' is shown as<br>
<br>
Apparent identifier binding<br>
in phase 0:<br>
defined in: test-lang/more<br>
as: bar.4<br>
imported from: test-lang/more<br>
<br>
where as in the buggy version (with the require in test-lang/main.rkt) it is<br>
<br>
Apparent identifier binding<br>
none<br>
<br>
This looks like some magic happens even before the first macro<br>
expansion - I need a magician to figure that out! ;-)<br>
<br>
Konrad.<br>
</blockquote></div>