[bitc-dev] Extending mutability inference
Jonathan S. Shapiro
shap at eros-os.org
Tue Jul 25 02:25:34 EDT 2006
As I have already said, the current rule is "strip outermost
mutability". However, in principle we could extend this to the reference
boundary. For example:
(defstruct (S 'a 'b):val a:'a b:'b)
(define (f s:(S (mutable int32) int32)) ... ())
and then say that the *external* type of "f" was
f : (fn (S int32 int32) ())
This "downgrade" is legal exactly when we know that things of type 'a
will always be copied. In particular, it would NOT be legal if the type
S were defined as:
(defstruct (S 'a):val a:'a b:(ref 'a))
because that would lead us into the multiple location types problem.
Similarly, it is not legal if S is a reference type.
This doesn't actually have that much impact on inference, because we
don't infer structure types in any case. It's mildly (but only *very*
mildly) interesting for array type inference.
The question: should value types be considered to be compatible if they
match ignoring mutability (up to any ref boundary)?
Swaroop has suggested that this may weaken our ability to infer types
successfully. Hopefully he can share some examples of that.
shap
More information about the bitc-dev
mailing list