Remix.run Logo
FL33TW00D 10 months ago

The array syntax is very offensive: `const a = [3]i32{ 1, 2, 3 };` A set is denoted by braces, not an array.

throwawaymaths 9 months ago | parent | next [-]

1. using [] drops context-freeness. what is: foo[1]? is that foo type array with one element? or accessing the foo array at index 1?

2. how do you feel about array initialization in C?

3. you can think of {...} as defining memory regions, curlies around code are defining "a memory block of instructions"

klysm 9 months ago | parent | prev | next [-]

According to your familiarity yes, but how is this such a problem? It’s easy to get past

FL33TW00D 9 months ago | parent [-]

Yes it is according my familiarity, but set notation has been the same since the 1870s, why should this language fuck it up? Rust does it correctly.

CooCooCaCha 10 months ago | parent | prev [-]

This is exactly why I find the language unintuitive. I don't understand why they made the choices they made. For example, why curly brackets?

I find the rust equivalent much more intuitive `let a: [i32; 3] = [1, 2, 3];`

andyferris 10 months ago | parent | next [-]

It’s targeting C/C++ programmers accustomed to initializer lists in C/C++.

throwawaymaths 9 months ago | parent | prev [-]

you couldn't do that in zig because a type is potentially a valid value:

.{i32, 3} is a valid term in zig.