[bitc-dev] Type compatibility at application

Jonathan S. Shapiro shap at eros-os.org
Fri May 19 14:25:54 EDT 2006


> OK. Are you thinking of a case like:
> 
> (define (f x:(vector 'a) #t)
> 
> (define vec1:(vector int32)  (vector 1 2 3))
> (define vec2:(vector (mutable int32)) (vector 1 2 3 ))
> 
> (define vecApp
>     (begin
> 	(f vec1)
> 	(f vec2)
> )

Yes. I am thinking of exactly this. And here is the weird part: if F can
operate correctly on (vector (non-mutable T)), then it will operate
equally correctly on (vector (mutable T)). There is a subtyping thing
going on here. The complication is contravariance.

> The solution may be an optimization that the polyinstantiator can 
> perform -- if there are two instantiations that only differ in the 
> mutability of arguments, only one of them needs to be emitted during 
> code generation.

Maybe. But the difference in mutability cannot be based simply on
shallow analysis.

This is definitely an issue for later, not for now.


shap



More information about the bitc-dev mailing list