Implemented array types in my toy language's new IR-based Aarch64 compiler! Arrays (fixed-size only) are first-class value types, can be passed to/from functions, copied, etc, and generally behave similarly to structs.

I think that's about it feature-wise of what I wanted to add to the language in this iteration. Probably gonna try implementing something substantial in it later to see if it feels the way I wanted it to (and fix a ton of inevitable bugs in the compiler)

@lisyarus I know nothing about the language except what I see here, but it looks nice.

There is one thing about the code that I dislike though: using *ptr to access ptr[0]. It makes it unclear that ptr points to an array. I would like it to have operator* only work on pointers to values, not on pointers to arrays.

Anyway, I'm just someone on the internet, so feel free to disagree. 😇

@wijnen In general it's impossible to distinguish pointer to array from a pointer to a single value without some serious changes to the type system, and generally I don't really think it's necessary (that's how it works in C and C++ as well)

@lisyarus Yes, I dislike it in C and C++ as well. 😅 That's why when I see a new language, I think 'here's an opportunity to do better'.

I don't understand why it would be hard, though. Obviously, they are the same in machine language, but that's because it doesn't have types at all. If the compiler knows what arrays are, and it knows 'pointer to X' as a type, it surprises me that 'array of N values of Y' is not a valid value for X.

But I trust you that it's harder than it seems to me. 😊

@wijnen I didn't say it's hard! It's very much doable. The thing is that any addition to the language unavoidably complicates it (thus also the compiler), so I have to filter out stuff that I personally deem unnecessary / not fitting the vibes of the language / etc (mostly based on feelz and guessing)
@lisyarus That is perfectly valid, of course.