[rust-dev] Managed & owned boxes in Rust

Tom Lee rust-dev at tomlee.co
Thu Dec 6 22:49:44 PST 2012

Ah awesome. Thanks! I've updated the blog post with your explanation. :)


On Wed, Dec 5, 2012 at 6:07 PM, Niko Matsakis <niko at alum.mit.edu> wrote:

> Great article.  Regarding why ~[T] and ~T behave somewhat differently, the
> reason is that the size of [T] is not known to the compiler!  It's kind of
> like how in C, if you have T[3], that's a perfectly fine type, but T[] is
> sort of a degenerate type that gets converted to T* willy-nilly.  The
> reason is that the compiler can't really manipulate an "unknown number of
> T's in a row", which is what [T] (Rust) and T[] (C) represent.  As an
> example, it can't put such a value on the stack, since it doesn't know how
> much stack space to allocate (well, it can't put that on the stack without
> using alloca() or something similar).
> Niko
> Tom Lee wrote:
>> Hey folks,
>> Don't mean to spam, but I wrote a blog post last night about memory
>> management in Rust as I understand it, both based on my own experience with
>> the language so far and a few conversations on the #rust channel:
>> http://tomlee.co/2012/12/**managed-and-owned-boxes-in-**
>> the-rust-programming-language/<http://tomlee.co/2012/12/managed-and-owned-boxes-in-the-rust-programming-language/>
>> If anybody's up for giving it a read over, I'm really keen to know if I'm
>> "getting it" or if I'm still confused :) I think I'm essentially rewording
>> what's in the tutorial, but for some reason I struggled to digest the
>> details for a while.
>> I'm still not sure I understand why the exchange stack is exposed
>> syntactically if you can't directly use it to transfer ownership between
>> tasks (i.e. you still have to resort to pipes etc. which use the exchange
>> stack under the hood).
>> Appreciate any clarification or thoughts!
>> Cheers,
>> Tom
>> ______________________________**_________________
>> Rust-dev mailing list
>> Rust-dev at mozilla.org
>> https://mail.mozilla.org/**listinfo/rust-dev<https://mail.mozilla.org/listinfo/rust-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20121206/a8994a59/attachment.html>

More information about the Rust-dev mailing list