Since no one else has mentioned it: in case you’re using nested arrays as multidimensional numeric arrays, and want a simpler life, it’s worth taking a look at crates like ndarray. There’s also various linear algebra crates if you’re really trying to do vectors and matrices etc.
One thing I haven't seen mentioned yet (I was about to, but then there were some shenanigans, now they seem to be properly moderated), is an example of actual parsing ambiguity in C/C++ caused by having the type declaration first, namely the "Most Vexing Parse".
It's a case where C/C++ compilers will run into problems, partly because of the type declaration coming first.
Here's a previous discussion about this topic:
I am not tagging or quoting because I am new and I can't with multiple users, anyways..
to scottmcm: no its not
also std::array<int, 10> is type first it just has a template
to H2CO3: I disagree takes much less effort to write
int a; then
let a[i32,0] thats 5 more characters to type.
also just because its easier to parse doesn't means its better or we would have more prefex notation for expressions.
to ZiCog: see I like the
int too it makes more sense to me maybe c's parser was complex because they did
int name which is like having the type on both left and right side.
to piter: I like the idea of rust and I am still trying to learn it. but I agree I hate some of the syntax
to steffahn: the idea was that your were settings the array to a default value of 5.
I thing it makes more sense then setting it in a brace due to '=' being assignment
to gkcjones: ty I will look at it
to bes: is this have to do with prefex notation or c's double siding type deceleration for arrays?
to trentj: ty
The point is that it's preferred even if it's longer than int a.
But are those 5 characters really that important? And if they are really that important aren't they compensated by all the times that type inference lets you declare a variable with just
let, without spelling the whole type?
Also, neither of those two code snippets are valid C/C++ or Rust code.
There are examples in the linked page. Mainly it has to do with a combination of prefix notation and a weird syntax for function arguments.
There are also other ambiguities, for example
T**c; may be either a declaration of a variable named
c with type
T** or a multiplication between the variable
T and the value