[racket] Typed macros in untyped code

From: Neil Toronto (neil.toronto at gmail.com)
Date: Thu Nov 18 20:01:18 EST 2010

Sam Tobin-Hochstadt wrote:
> On Thu, Nov 18, 2010 at 7:48 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
>> Why aren't typed macros allowed to be used in untyped code? Don't the
>> annotation forms like (: ...) expand to no-ops?
> This is an important limitation - the typed macros have access to the
> unprotected versions of the typed identifiers from the module, so they
> can't be allowed to escape.  There are plans to evolve the certificate
> system so that we can lift this restriction, but that's future
> research.

Ahh! There is a reason for the madness! I'm still miffed, but I like 
this kind of miffing. Miffingness. Miffilocity.

>> 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?
> Require `#%top-interaction' from typed racket, or in general create
> your sandbox from Typed Racket.

Excellent, a workaround. Requiring #%top-interaction sounds hacky, so 
I'll do the other one. It'll be nice to have my examples type-checked 

Neil T

Posted on the users mailing list.