On 11-07-14 10:34 AM, Patrick Walton wrote:

After the conversation among Dave, Dan Grossman, and me yesterday, I
actually think that we don't want "accessing things through blocks" at
all. I believe it's impossible to make memory-safe. Consider:

let h1 = @hashmap::mk();
let h2 = id(h1); // identity fn; compiler can't see through this
hashmap::insert(*h1, "foo", "bar");
hashmap::get(*h1, "foo", { |&val|
hashmap::delete(h2, "foo");
print val; // crash
});

I think we *have* to copy the values. (Note that we are already copying
the values to please the alias checker in the hashmap implementation, so
this adds no more overhead than what we have!) This gives get() a more
natural return value, making the "accessing things through blocks"
pattern pointless. So the problem goes away.

I disagree. The delete is the prohibited bit (by type-based interference with *h1; best the compiler can do due to the id() call it can't see through). Accessing &val in a read-only sense should be safe.

-Graydon

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to