logoalt Hacker News

FL33TW00D04/01/20253 repliesview on HN

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


Replies

throwawaymaths04/02/2025

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"

klysm04/02/2025

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

show 1 reply
CooCooCaCha04/01/2025

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];`

show 2 replies