[racket-dev] promise vs polym contracts

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Fri Jul 6 19:12:19 EDT 2012

On Fri, Jul 6, 2012 at 6:53 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
> I don't care about typed definitions.

Sam didn't have a "typed" definition, just a "type" definition, note
the significant "d" suffix.

> And yes, in an untyped world, you'd write
> (define (sum lt)
>   (cond
>     [(promise? lt) lt]
>     [else (+ (sum (car lt)) (sum (cdr lt)))]))

In an untyped world, you could write the same function that Sam did.

> Note the mistake you made in forcing too early.

Sam didn't force anything too early.  He only forced anything in the
branch that accepts promises.


Posted on the dev mailing list.