[racket-dev] a small Racket success story

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Wed Aug 18 07:59:59 EDT 2010

On Tue, Aug 17, 2010 at 9:21 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> we couldn't type the generator code (a bad interaction between mutation
> and occurrence typing).

In almost all cases, when TR rejects your program because of this,
your code is incorrect in the presence of threads and/or futures (and
sometimes continuations) as well.  For example, this program:

#lang typed/racket

(: x Any)
(define x #f)
(: f (Any -> Void))
(define (f v) (set! x v))

(if (number? x)
    ;; no call to `f' here
    (add1 x)
    0)

won't typecheck, but you might think it should.  However, the call to
`f' can be in another thread/future, which can happen between the test
and the `add1', breaking your program.
-- 
sam th
samth at ccs.neu.edu


Posted on the dev mailing list.