On Thu, Nov 7, 2013 at 5:03 AM, Gaetan <gae...@xeberon.net> wrote:

> Hello
>
> I really the concept of owned pointers, and I'm wondering if it could be
> the default.
>
> I mean, the more I use it, the more I tend to use it everywhere, and it
> seem any "average" user-code (ie, not the rust compiler itself) will have a
> lot of "~var" anywhere, "let i=~5", ..., more than the other variable
> initialization. Look at the unit tests for libstd or libextra.
>
> Why not having the default syntax be owned pointers, and the ~ syntax (or
> another one) be the syntax for creating variable on the heap?
>
> let i=5; // owned pointer
> let j=~5; // heap value
>
> Regards,
> -----
> Gaetan
>

Owned boxes shouldn't be commonly used. There's close to no reason to use
one for anything but a recursive data structure or in rare cases for an
owned trait object.

http://static.rust-lang.org/doc/master/tutorial.html#boxes

It's important to note that ~[T] and ~str are not owned boxes. They're just
sugar for dynamic arrays, and are common containers.
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to