3 ms·
The array syntax is very offensive: `const a = [3]i32{ 1, 2, 3 };` A set is denoted by braces, not an array.
by FL33TW00D 2y ago
The array syntax is very offensive: `const a = [3]i32{ 1, 2, 3 };`
A set is denoted by braces, not an array.
- CooCooCaCha 2y agoThis 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 2y agoIt’s targeting C/C++ programmers accustomed to initializer lists in C/C++.
- throwawaymaths 2y agoyou couldn't do that in zig because a type is potentially a valid value: .{i32, 3} is a valid term in zig.
- klysm 2y agoAccording to your familiarity yes, but how is this such a problem? It’s easy to get past
- FL33TW00D 2y agoYes 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.
- throwawaymaths 2y ago1. 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"