box syntax question

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

box syntax question

Oscar Boykin
Once in the tutorial, I see this syntax:

let x = box(GC) [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10];

It seems to me, that should be: box<Gc>, as it feels like box is referring
to a container type (which the default type is Box<_>, but may be Rc<_> or
Gc<_>).

What is the principle behind the current notation? What is "GC" is this
context other than a special string that is a one-off syntax?
--
Oscar Boykin :: @posco :: http://twitter.com/posco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140702/ad762e17/attachment.html>

Reply | Threaded
Open this post in threaded view
|

box syntax question

Corey Richardson
The full syntax is: "box" ["(" EXPR ")"] EXPR

The first expression is the "boxer", or where the result of the second
expression will be stored. GC and HEAP are special cased right now as
the only boxers, but the goal is to use a trait such that you can use
Rc, arenas, vectors, or any other arbitrary type as a boxer.

On Wed, Jul 2, 2014 at 7:29 PM, Oscar Boykin <oscar at twitter.com> wrote:

> Once in the tutorial, I see this syntax:
>
>
> let x = box(GC) [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10];
>
> It seems to me, that should be: box<Gc>, as it feels like box is referring
> to a container type (which the default type is Box<_>, but may be Rc<_> or
> Gc<_>).
>
> What is the principle behind the current notation? What is "GC" is this
> context other than a special string that is a one-off syntax?
> --
> Oscar Boykin :: @posco :: http://twitter.com/posco
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>



--
http://octayn.net/

Reply | Threaded
Open this post in threaded view
|

box syntax question

Benjamin Striegel
To expand upon what Corey was saying, `box` is basically a huge
special-cased hack right now. I'm surprised that a mention of `box(GC)` is
even included in the tutorial. Someone tell Steve to rip that out. :P

We'll be clarfiying how best to use `box` before 1.0. In the meantime, just
don't use GC. Like, at all. You don't need it! :)


On Wed, Jul 2, 2014 at 10:39 PM, Corey Richardson <corey at octayn.net> wrote:

> The full syntax is: "box" ["(" EXPR ")"] EXPR
>
> The first expression is the "boxer", or where the result of the second
> expression will be stored. GC and HEAP are special cased right now as
> the only boxers, but the goal is to use a trait such that you can use
> Rc, arenas, vectors, or any other arbitrary type as a boxer.
>
> On Wed, Jul 2, 2014 at 7:29 PM, Oscar Boykin <oscar at twitter.com> wrote:
> > Once in the tutorial, I see this syntax:
> >
> >
> > let x = box(GC) [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10];
> >
> > It seems to me, that should be: box<Gc>, as it feels like box is
> referring
> > to a container type (which the default type is Box<_>, but may be Rc<_>
> or
> > Gc<_>).
> >
> > What is the principle behind the current notation? What is "GC" is this
> > context other than a special string that is a one-off syntax?
> > --
> > Oscar Boykin :: @posco :: http://twitter.com/posco
> >
> > _______________________________________________
> > Rust-dev mailing list
> > Rust-dev at mozilla.org
> > https://mail.mozilla.org/listinfo/rust-dev
> >
>
>
>
> --
> http://octayn.net/
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140702/cae54af6/attachment.html>

Reply | Threaded
Open this post in threaded view
|

box syntax question

Igor Bukanov
In reply to this post by Corey Richardson
So at some future point it would be possible to replace
TypedArena_instance().alloc(X) with box(TypedArena_instance) X
avoiding an extra move of X from a temporary allocated on the stack
that the compiler in general cannot optimize?

On 3 July 2014 04:39, Corey Richardson <corey at octayn.net> wrote:

> The full syntax is: "box" ["(" EXPR ")"] EXPR
>
> The first expression is the "boxer", or where the result of the second
> expression will be stored. GC and HEAP are special cased right now as
> the only boxers, but the goal is to use a trait such that you can use
> Rc, arenas, vectors, or any other arbitrary type as a boxer.
>
> On Wed, Jul 2, 2014 at 7:29 PM, Oscar Boykin <oscar at twitter.com> wrote:
>> Once in the tutorial, I see this syntax:
>>
>>
>> let x = box(GC) [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10];
>>
>> It seems to me, that should be: box<Gc>, as it feels like box is referring
>> to a container type (which the default type is Box<_>, but may be Rc<_> or
>> Gc<_>).
>>
>> What is the principle behind the current notation? What is "GC" is this
>> context other than a special string that is a one-off syntax?
>> --
>> Oscar Boykin :: @posco :: http://twitter.com/posco
>>
>> _______________________________________________
>> Rust-dev mailing list
>> Rust-dev at mozilla.org
>> https://mail.mozilla.org/listinfo/rust-dev
>>
>
>
>
> --
> http://octayn.net/
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev

Reply | Threaded
Open this post in threaded view
|

box syntax question

Patrick Walton-2
On 7/2/14 11:08 PM, Igor Bukanov wrote:
> So at some future point it would be possible to replace
> TypedArena_instance().alloc(X) with box(TypedArena_instance) X
> avoiding an extra move of X from a temporary allocated on the stack
> that the compiler in general cannot optimize?

Yes. Under the hood, this will be implemented via return value
optimization and an unboxed closure.

Patrick