[racket-dev] Motivation for polymorphic opaque types

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sun Jan 6 15:03:03 EST 2013

On Sun, Jan 6, 2013 at 2:55 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> What if you added an extra field to immutable values (ie all TR structs
> would have this hidden field) such that, when they passed across a boundary,
> the field got mutated to say what type it passed at. Then, when the value
> passed back into TR, TR could check to see if has this secret field and what
> the type was and then avoid more checking.

The problem is that this info isn't available anywhere (and I'm not
sure it's really sensible).  Consider the `cons` function (on lists
only).  If you write `(cons 'hello empty)` in untyped code, what type
should get inserted, and where should that be calculated?  This
calculation can't really be done both automatically and correctly
ahead of time, and would add a bunch more expense.

Sam

Posted on the dev mailing list.