On 03/10/2010 12:27 AM, Jeffrey Yasskin wrote:
Well, I see two ways to handle this problem, although there may be
more subtle problems lurking:
1) C++'s const qualifier on methods, which says that such methods
stick around on frozen versions of objects. Probably not good for
Rust.
Yeah, don't really like that one. Equivalent to making it illegal to lie
about the state-mutation effect; if we're going to do that, might as
well just bite the bullet. But I think users would prefer a less-perfect
'freeze' operator to an un-bendable effect. At least I would. Maybe I'm
imagining that preference.
2) Recursively remove "mutable" from the frozen object's arguments,
and then re-typecheck the methods. Methods that fail are removed from
the frozen type. Since surprise.set would fail to typecheck if 'x'
weren't mutable, it would give a "method not found" error at your
"oops" line. Similarly for captured arguments in frozen functions.
Nope, object method bodies are opaque at the point we're doing the
freeze; we don't know which methods implement the interface.
-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev