On 02/10/2010 2:14 PM, David Herman wrote:
I think what you're describing here is roughly the difference between saying "types have effects" and "function types have effects". In the effect system literature, effects are placed above the arrow of a function type to indicate this distinction, e.g.:io int --> bool It sounds right to me that effects are a property of function and method types, rather than all types.
Yes.
And IIUC, it sounds like the other concept you're introducing, which is a property of all types, is something like a memory storage classifier, and a property of all types. Yes?
Yup.
- I think typestate can ensure that after you freeze something, you don't make local mutations to it, but how do you enforce that you haven't leaked the alias to someone non-local who might retain a mutable view of the data?
Same as when transmitting immutable values across domains (that is, between threads): the frozen version is a "detached" value. IOW the operation ensures that you're singly-referenced all the way down, making copies anywhere you're not. This would be a slightly modified version of detachment that only applies to the stateful substructures, but the idea is the same.
If you do have restrictions in mind that make these operations safe, in what situations can you usefully use freeze and thaw?
Hopefully all contexts. I don't have any other restrictions in mind; did you have any you were thinking of?
As for the idioms you mention, the second one sounds compelling, but I'm not sure about the freeze-and-apply-predicate. That seems sort of question-begging -- the only reason you'd use freeze-and-apply-predicate is if you were already going to freeze anyway, because you were all done mutating the data.
Yes. Perhaps we're talking across purposes? The predicate classifies the frozen datum into a narrower type than the un-qualified one, but can't be applied to stateful data. Consider:
let tup(mutable int, mutable int) m_foo = bar(); m_foo._0 += 10; let tup(int,int) foo = freeze m_foo; // Ordered_pair makes foo narrower than tup(int, int) // but could not be applied to m_foo, since it's stateful. check ordered_pair(frozen); // So now you can make this call: subsystem.that.only.wants.ordered_pairs(foo);
- State values could also have a our structural comparison definition extended to them. Again, acyclicality wins here.[2]Same question as Patrick: how do you enforce acyclic stateful types?
Cyclic types are recursive types where one of the recursive edges is mutable. We can identify both those facts -- mutable fields are denoted, and recursion has to go through tags -- so I don't really see the hard part. Why wouldn't we be able to identify them?
Stratum is pretty stilted, yeah. No brilliant ideas ATM, though.
K. Keep your ears open for one :)
What would == do for gc types? Fail dynamically? Fail to type check?
Fail to type check. -Graydon _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
