I can’t even get past the simple values syntax:
var value: i32 = 0;
This looks like you’re assigning the value 0 to i32, a type. It’s nonsensical. Also what is the purpose of the var keyword? Why not put the type there?The array syntax makes even less sense!
I think what you’re missing in your examples is how the values are used after declaration. C syntax was designed so that declaration resembles use. The reason array subscript brackets come after the variable name is because that’s how you access elements of the array:
int arr[3] = { 12, 76, -42};
arr[1] += 4;
if (arr[2] < 0) { printf(“it’s negative!\n”); }Same goes for pointers.
int *foo = &bar;
*foo = 1;
As far as syntax goes, tying the pointer to the identifier doesn't make sense to me, at least. Pointers associated with types makes much more sense: int* foo = &bar;
C++ thinks so too.
[0]: https://nathancraddock.com/blog/consistency-in-zigs-type-sys...