I'm not sure what I think about this, but we could do away with the `as`
cast operator and replace it with `.to_f32()`. I was already planning on
adding a ToInt/FromInt for casting to and from enums, so we'll probably
grow `.to_f32()` and etc anyway. I doubt we could use `.to_f32()` in a
pattern.

Or we could change the cast operator. `<expr> : <type>` has some nice
symmetry with the rest of the syntax. I'm not sure if that would be
ambiguous though. Scala uses this syntax:

val x = 1


x: Int = 1

val y = x: Float

y: Float = 1.0


O'Caml uses `<expr> :> <type>` to cast polymorphic variants, as in:

# let x = `A;;
val x : [> `A ] = `A
# let b = (x :> [> `A | `B]);;
val b : [> `A | `B ] = `A

I'm not sure if either of these options is the right way to go though.


On Thu, May 2, 2013 at 6:16 PM, Tim Chevalier <[email protected]>wrote:

> I don't particularly like any of the options here, but "as" seems like
> the least bad one. Matching on a casted constant seems like a pretty
> rare case, and you can always use if instead of match. I agree that
> the existing @ syntax is ugly, and I think using '=' for pattern
> binding muddies the waters (besides the ambiguity).
>
> Cheers,
> Tim
>
>
>
> --
> Tim Chevalier * http://catamorphism.org/ * Often in error, never in doubt
> "Too much to carry, too much to let go
> Time goes fast, learning goes slow." -- Bruce Cockburn
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to