On Fri, Nov 15, 2013 at 7:27 AM, spir <[email protected]> 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.

The `range` function will return an iterator based on the type passed
to it. If you use `0u8` instead of `0` it will provide an
`Iterator<u8>` implementation.

I don't think we should play around with `for` loops anymore until
they're reimplemented inside the compiler instead of as a parser hack.
A type annotation can be added in a backwards compatible way though.

> 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.

I don't think either is a good default. Fixed-size integers do not
belong in most application-level logic.

https://github.com/mozilla/rust/issues/6023
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to