On 15/11/13 23:27, spir wrote:
These are 2 points of secondary importance (or even less).
What about the following pattern:
for x:Type in expr {
// proceed with x
}
as equivalent to:
for y in expr {
let x = y as Type;
// proceed with x
}
both for iterator loops and range loops?
Actually, my need is to have uint's or u8's in range loops, while the
default is int.
I'm also unhappy with "let n = 1;" yielding by default an int instead
of an uint. I would suggest that if an int value is unsigned, the
default type is uint. A signed int is, semantically, a difference,
thus always signed: to get a default signed int, just write "let n =
+1;". Seems both logical and self-documenting, imo.
Again, quite unimportant and definitely not of high priority. Just
sending this for the record.
Denis
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev
I'd like being able to write `pattern: Type` and `expression: Type` in
arbitrary contexts, forcing the LHS to have that type, so `let (a: u8,
b: f64) = foo(1: int);` would be valid (this would cover for-loops,
since they are pattern contexts); I know it's been mentioned before, but
I couldn't find any issues already, so I filed it as #10502.
In any case, you can write `range(0u8, 10)` or `range(0u, 10)` to
override the inference and get a u8 or uint range, respectively.
BTW, Removing the int default has actually already been suggested in #6023.
6023: https://github.com/mozilla/rust/issues/6023
10502: https://github.com/mozilla/rust/issues/10502
Huon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev