On 2/7/12 4:31 PM, Graydon Hoare wrote:
Really? I think our concept quite closely mirrors most languages that mix mutable and immutable types. Either can nest in either, and saying something is mutable or immutable is only a statement about one level of nesting.

I agree that we mirror existing languages, but I disagree that this makes it safe. Most languages with which I'm familiar, like O'Caml, don't have this issue because they do not have interior record types. Languages which do, namely C++, have special rules.

For example, in C++ you cannot have a const field of value type unless all fields within that type are const. Compiling this program in gcc, for example:

struct foo { const int x; };
struct bar { foo f; };

void test(bar *b, foo f) {
b->f = f;
}

yields the following error: "non-static const member ‘const int foo::x’, can't use default assignment operator".



Niko
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to