Thanks for the clarification. The current design actually makes sense to me after re-reading about dynamically sized types.
On Friday 08 November 2013 09:29:37 Patrick Walton wrote: > On 11/8/13 7:47 AM, Diggory Hardy wrote: > > What's wrong with sticking with convention here? E.g. C++'s `string` and > > `vector<T>` are objects containing two or three pointers. D's arrays and > > `string` act the same way. Even C's dynamic arrays (`int x[]`) can be > > thought of the same way (if one avoids thinking of them as pointers). > > Because: > > * We need slices in the language. They're important for soundness. > > * We need dynamically sized types in the language in order to be sound > around first-class trait objects. > > * Given that we need slices, and we need dynamically-sized types, we can > avoid introducing more concepts in the language by treating slices as > just a special case of a dynamically-sized type. That is, a slice is > nothing more than *a pointer to a dynamically-sized type*. > > * The pointer sigil is notated `&`, and the dynamically-sized type is > `[int]`. So the resulting notation is `&[int]`. > > You can see slices as just pointers with a length attached; i.e. a > pointer to multiple contiguous values. In fact, Cyclone called them "fat > pointers" instead of "slices". In Cyclone, you wrote a slice as `int > *fat`. (Notice the similarity to `&[int]`.) > > Note that not all of this is implemented today, which is leading to some > of the confusion in this thread. Felix Klock is currently working on it. > > Patrick > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
