On 9/17/11 12:18 PM, Marijn Haverbeke wrote:
Three points: Our current closures are so neutered (they can only appear as function call arguments) that doing reference analysis on them is trivial (just descend into the closure during the analysis). Sully is considering an extension them which, if I understand it correctly, will still be checkable without any acrobatics.
I'm less concerned about blocks than I am about @fn (which we still have AFAIK) and objects.
You seem to believe that type-based alias analysis is complicated. This may be me using the term wrong, but it the thing I'm doing, whatever it's called, is entirely trivially easy. Basically, it's the 45-line function at [1] which, when dealing with references to things that might be overwritten in a way that can't be statically seen, simply checks whether any value is touched that may include the type that has to be mutated to overwrite the referenced value. There's nothing hard or complicated about this.
I don't think this is trivial or easy. Whenever you perform an assignment, you have to think about whether a set of types (the aliases read later in the control flow) is contained within the type you're assigning to. This is a cognitive burden and is also action-at-a-distance.
Additionally, there's still the problem of @fn and obj.
(And, as an aside, it is quite a bit more advanced than the alias burying you describe here. We have a few properties in Rust, 'no global data' and 'mostly immutable data structures' that make this style of analysis possible. I'm going to write up some kind of paper when the thing has stabilized. But for now, I'd like everybody to realize that they're programming with safe references, and they hardly ever have to think about it. This is no mean feat!)
But I do keep hitting issues with the alias analysis. Every so often I have to make copies to satisfy the alias checker, usually after calling a closure. It's hard for me to predict.
Patrick _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
