On 4/2/14 9:25 AM, Daniel Micay wrote:
On 02/04/14 11:35 AM, Alex Crichton wrote:
I've noticed recently that there seems to be a bit of confusion about the fate
of ~[T] with an impending implementation of DST on the horizon. This has been
accompanied with a number of pull requests to completely remove many uses of
~[T] throughout the standard distribution. I'd like to take some time to
straighten out what's going on with Vec<T> and ~[T].

I think this is a difference of opinion, not "confusion". The original
pull requests switching `~[T]` to `Vec<T>` were done by pcwalton, and
this was with full knowledge of the plans for `~[T]`.

It was transitionary. I thought that we would have to fully extract `~[T]` from the language before DST would work, but it now seems likely that that won't need to happen.

The `~[T]` type will exist because `[T]` will exist as a type. It won't
be an explicit choice to support having it. Some of us consider it an
unfortunate consequence of DST rather than a useful type.

Even if you buy that `~[T]` is useless (which I'm not sure I do), it's no more unfortunate than the fact that the type system allows useless types like `Rc<Rc<Rc<int>>>` is unfortunate.

If `~[T]` remains used throughout the libraries, Rust will become
noisier than languages like C++ with a unified vector type. The need to
convert between `Vec<T>` and `~[T]` would add noise to lots of code,
without any adding measurable optimization win. A micro-optimization
shouldn't drive the design of the libraries, especially when it will
prevent making a significant *macro*-optimization (passing a length to
the deallocation function).

In practice C++ libraries use their own custom vector types all over the place, so I wouldn't say that Rust is going to be significantly noisier no matter what we do. Interoperability between different libraries is not a strong point of C++.

Besides, C++ has this too, with `unique_ptr<T[]>`. This Stack Overflow answer is actually pretty illuminating:

http://stackoverflow.com/questions/16711697/is-there-any-use-for-unique-ptr-with-array

I think that length-frozen owned vectors are likely to be surprisingly common. We'll see.

Patrick

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

Reply via email to