On 2/10/12 6:32 AM, Niko Matsakis wrote:
we could still keep the alias checker in the code base, as it can
provide very useful guarantees for reasoning about your program, but I
would prefer if the user has to "opt-in" to use it. [1]
I forgot to spell out what I had in mind. Basically it'd be a safe
version of ANSI C's restrict keyword. A function could declare that its
parameters MUST not be aliased. I'm not sure how well this would work
in practice but it could be pretty nice to have. In particular, I could
imagine it being combined with a check predicate of sorts, so that you
could write something like:
fn foo(x: @T, y: @T) {
check distinct(x, y);
memmove(x, y); // or whatever
}
fn memmove(x: @T, y: @T) : distinct(x, y) { ... }
Anyway, this is just a random thought.
I have to say though that my opposition to alias analysis has somewhat
softened now that I better understand the guarantees that the alias
checker is trying to enforce. Before I had a vague sense of what they
were and it felt kind of frustrating to have to insert copies for
reasons I did not fully understand. However, if we try to move to a
more flexible system like regions, I do not think it will be possible to
simply forbid aliases as we do now, because part of the goal of that
system is to allow for pointers to be used more naturally, which often
includes aliasing.
Niko
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev