[racket-dev] Typed versions of untyped collections

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Dec 17 17:55:37 EST 2012

On Dec 17, 2012, at 5:43 PM, Neil Toronto wrote:

> On 12/17/2012 02:44 PM, Matthias Felleisen wrote:
>> 
>> My understanding is that
>> 
>>  -- Neil created a single file P, I believe it is typed
>>  -- he tells you to load plot/typed/ for the typed version
>>  -- he tells you to load plot/ for the untyped version
>> 
>> Somewhere in this arrangement a call in some untyped client to a
>> function f from P will cross a line.
>> 
>> If this is wrong, I'd like to know where it goes wrong.
> 
> You're thinking of `math/array', which is written in Typed Racket. There *is* a big performance problem with arrays in untyped code, because arrays are basically higher-order functions. Getting elements from arrays that cross the contract barrier is expensive.

Okay. 


> `plot' is written in untyped Racket. There's no performance problem with typed plots at all; in fact, using `plot/typed' from TR code ends up checking exactly the same contracts for the same plots. `plot/typed' is just another end-user that happens to re-export everything with types attached.

I don't understand this last part at all. You have 

-- an untyped file M 
-- a typed file T that imports M and re-exports everything from there with types 

How can it possibly be the case that a client C imports T and does NOT pay for the contracts that T's types impose on the call chain? 

-- Matthias





Posted on the dev mailing list.