[racket] TR: scope of universally quantified type variables is ... very strange?

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Thu Jan 5 20:32:05 EST 2012

On Thu, Jan 5, 2012 at 11:56 PM, John Clements
<clements at brinckerhoff.org> wrote:
> I wrote a piece of code like this without thinking:
>
> #lang typed/racket
>
> (: f (All (T) (Number -> T -> T)))
> (define ((f x) y)
>  (ann y T))
>
> ... and then, after a second, was sort of flabbergasted that it worked.  What's the scope of the type variable T? Apparently I can use it anywhere in the definition of the identifier that it names? That seems really fragile. Am I misunderstanding this?

You're correct about the scope, and the fact that you wrote it without
thinking, and it just did the right thing, is precisely what I was
going for.  What's fragile here?

>
> John
>
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users
>



-- 
sam th
samth at ccs.neu.edu



Posted on the users mailing list.