[racket] Typed Racket macros in untyped code

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Thu Sep 15 22:29:03 EDT 2011

Currently macros written from Typed Racket can not be used in the
untyped world.
Example:

#lang racket/load

(module t typed/racket
  (provide foo)
  (define-syntax (foo stx)
    #'(+ 2 1)))

(module u racket
  (require 't)
  (displayln (foo)))

(require 'u)

This was brought up on the list a while ago, and the answer was that
when the certificate system needed work before this was feasible. My
question is: are taints the feature that was needed? And has any
progress been made towards this?

Also as a work around the following program works:


#lang racket/load


(module t2 racket
  (require typed/racket)
  (provide foo)
  (define-syntax (foo stx)
    #'(let ()
        (: x Number)
        (define x (sqrt 2))
        x)))


(module u2 racket
  (require 't2)
  (displayln (foo)))

(module tu2 typed/racket
  (require 't2)
  (: y Number)
  (define y (foo))
  (displayln y))

(require 'u2)
(require 'tu2)

Which seems to achieve what TR is currently preventing. Is this
unsafe/buggy, or is there another reason why it works when the
language is not typed?


Posted on the users mailing list.