[racket] Typed macros in untyped code

From: Neil Toronto (neil.toronto at gmail.com)
Date: Thu Nov 18 19:48:31 EST 2010

Why aren't typed macros allowed to be used in untyped code? Don't the 
annotation forms like (: ...) expand to no-ops?

I've been able to work around this apparently artificial limitation by 
defining typed macros in #lang racket modules where I required 
typed/racket. I could even re-export the macros in typed modules, import 
the re-exported macros in untyped modules, and use them. The macros can 
even expand to code that uses (: ...), and untyped code that uses the 
macros still works.

But Typed Racket craps on me if I use the typed macros inside a sandbox 
in Scribble. For example, using @(example #:eval my-eval (bftest-error 
(bfexp (bf 2)))) gives me this:

 > (bftest-error (bfexp (bf 2)))
   eval:63:0: Type Checker: Macro bftest-error from typed
   module used in untyped code in: (bftest-error (bfexp (bf
   2)))

Gah! I thought I got around this! How do I convince Typed Racket or the 
sandbox that I'm not up to anything funny?

Neil T


Posted on the users mailing list.