Re: [rust-dev] The meaning of 'box ref foo' ?

2014-05-30 Thread Kevin Ballard
Not only this, but match patterns are also extremely often used intentionally to move values. The trivial example is something like match some_opt_val { Some(x) => do_something_with(x), None => default_behavior() } By-ref matching is actually the more infrequent type of matching in my e

Re: [rust-dev] The meaning of 'box ref foo' ?

2014-05-30 Thread Benjamin Striegel
What you're overlooking is that patterns are used for more than just `match` expressions. They can also be used in both assignment statements and in function/closure signatures. For example, note that `x` and `y` are the same type in the following program: fn main() { let ref x = 3;

Re: [rust-dev] The meaning of 'box ref foo' ?

2014-05-30 Thread Emmanuel Surleau
I think the 'ref' keyword removal is a very good idea. It has bitten me several times, and the idea that pattern matching something essentially performs a side effect (moving the value) leaves me uncomfortable. Cheers, Emm ___ Rust-dev mailing list Rust

Re: [rust-dev] The meaning of 'box ref foo' ?

2014-05-27 Thread Igor Bukanov
I wonder if the idea of using ref by default in patterns for Copyless types has being considered? The need to move on pattern match should be infrequent. So it is better to use a special syntax for that case skipping box ref and similar in most of the code. On 28 May 2014 06:23, Corey Richardson

Re: [rust-dev] The meaning of 'box ref foo' ?

2014-05-27 Thread Corey Richardson
As with most things in Rust, in a pattern, a keyword means the *opposite* of its normal meaning. So where `box e` in an expression will box up the result of `e`, `box p` in a pattern will unbox `p`. On Tue, May 27, 2014 at 9:50 AM, Tommi wrote: > What is the meaning of this 'box ref foo' syntax f

[rust-dev] The meaning of 'box ref foo' ?

2014-05-27 Thread Tommi
What is the meaning of this 'box ref foo' syntax found in the tutorial over at http://doc.rust-lang.org/tutorial.html#references In short, it's: enum Shape { Sphere(Box) } let shape = Sphere(box 1.0f32); let r = match shape { Sphere(box ref radius) => *radius }; I thought the 'box' keyword