On 06/10/2012 12:14 PM, Graydon Hoare wrote:
On 10/06/2012 11:30 AM, Patrick Walton wrote:
I like this. The only concern, as a comment pointed out, is that "*"
might be slightly confusing; maybe "ref" is better.
I like it too. Though I wonder if the ambiguity between
&-as-a-reference-taker and &-as-a-pattern is actually problematic.
Consider two cases (assuming we use & here):
#1:
let foo = {1,2};
let {&a, &b} = foo;
#2:
let x = 1;
let y = 2;
let foo = {&x, &y};
let {&a, &b} = foo;
It seems to me that in both cases you're introducing two variables, a
and b, of type &int. In #1 they point into foo, using the & to "take
references" to the record components; in #2 they point to x and y
respectively, using the & to "match against" the existing &-types inside
the record.
But, as I understand it, in #2 they would actually copy out the values.
So in #1, a : &int and b : &int, but in #2, a : int and b : int. cf:
let x = 1; // x : int
let y = 2; // y : int
let foo = (@x, @y); // foo : (@int, @int)
let (@a, @b) = foo; // a: int and b: int
Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev