On 11/15/2013 11:05 AM, Gábor Lehel wrote:
Like C++, types could be parameterized over constants. Again, the syntax
could mirror their declarations. For example, a function to construct a
fixed-length array:
fn make_n<static N: int>(n: int) -> ~[int, ..N] { [n, ..N] }
Interesting questions here include what types to allow, how or whether
to handle literals of various types as type arguments, and the constant
expression sublanguage.
Personally I'd appreciate a type system that's able to express SI units,
which C++ and Haskell are powerful enough to do[1]. For example, if
using the right library,
let velocity = distance / time;
would be a compile error if the dimensions do not match up properly. I
added such a system to a C++ physics simulation and it caught some of
our mistakes.
*scurries off to learn Rust properly*
-Isaac
[1] C++: Boost.Units; Haskell:
http://www.haskell.org/haskellwiki/Physical_units
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev