[MLton-devel] types for RSSA

Stephen Weeks MLton@mlton.org
Mon, 18 Nov 2002 11:14:34 -0800


> I've never been convinced that flattening mutable fields into other data
> structures really buys you anything without a lot of linearity analysis.
> We still don't allow pointers into (the middle of) other data-structures,
> so I don't see where a vector of ref's could be flattened.  Presumably,
> somewhere you do  val r = Vector.sub(v, i)  and that ref escapes off into
> some other data-structure, the stack, etc.  As soon as that happens, you
> won't be able to push the refs into the vector. 

Sure.  But when a ref is only used in a second-class way, then you can
get rid of the indirection.  For example, consider the following code.

datatype t = T of int ref

val T r = t
val _ = r := !r + 1

If all uses of the ref are of the above form, then there is no reason
not to flatten it into t.

I think getting ref vectors is unlikely, and I personally would never
want to count on the optimizer getting it when I can so easily use an
array.  On the other hand, I agree with Henry that MLton may do enough
inlining that a whole-program analysis that looks at local snippets of
code involving refs extracted from tuples may be able to get
something.  I don't think that we need pointers into the middle of
data structures.


-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing 
your web site with SSL, click here to get a FREE TRIAL of a Thawte 
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel