On Sun, Oct 28, 2012 at 3:48 PM, Niko Matsakis <[email protected]> wrote:
>
> Regardless of whether manual memory management is desirable as an end
> goal, support for it is essentially required if you wish to permit tasks to
> exchange ownership of data without copies.

Is it fair to say that, in fact, you don't need to do manual memory
management in Rust *unless* you care about efficiently exchanging data
between tasks?

Some people panic at the thought of having to do manual memory
management, but (one might argue) it doesn't feel burdensome in Rust
because the only times you have to use it are times when you'd need to
be thinking low-level anyway -- so, really, it's good that the
language supports reasoning at a low level at the appropriate times.

> As a broader point, it turns out there are a LOT of type system things you
> can do if you know something about aliasing (or the lack thereof). Our
> current approach to freezing data structures for example is reliant on this.
> Safe array splitting for data parallelism—if we ever go in that
> direction—will be reliant on this.  And so forth.  So, supporting a
> unique-pointer-like construct makes a lot of sense.

+1.  Say that, for instance, you want to have a mutable vector that
can be split into two disjoint pieces (so that one task can write to
one piece, and a parallel task to the other), such that an error is
raised if either task touches the other one's piece.  In Haskell, I
think you could enforce this sort of disjoint access entirely at the
type level, using something like the ST monad trick, but then you've
got to layer the parallelism on top of that.  It's possible (I
think!), but it's really complicated.  But!  Rust isn't Haskell, it's
a systems language, and if as Niko is saying, we could accomplish
things like parallel disjoint array access so long as we're willing to
expose a little bit of low-level stuff, then that seems like a strong
argument for exposing that little bit of low-level stuff.  It seems
like a little low-level-ness in Rust will get you a long way.

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

Reply via email to