From 1500d99d7a64e1b3d9f22827b02adf34bed19ce7 Mon Sep 17 00:00:00 2001 From: Adam McDaniel Date: Sun, 8 Sep 2024 05:53:03 -0400 Subject: [PATCH] Improved web example --- CHANGELOG.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 210f9e5a..045bfb13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -185,4 +185,67 @@ println(main()); The compiler is significantly faster -- about 20 times faster at compiling the AES example. This is mainly due to the much faster parser implemented with Nom instead of Pest. There are also several optimizations with constant evaluation I added, along with optimizations -for how declarations are typechecked. \ No newline at end of file +for how declarations are typechecked. + + +## [0.1.1-alpha] - 2024-9-8 + +### Added + +Added `const` generics, so constant parameters can be passed along with types through templates. This allows the typechecker to be applied to many more aspects of code, including examples like typechecking dimensions of matrix multiplications at compile time. + +```rs +struct Matrix { + arr: [[T * Cols] * Rows] +} + +impl Matrix { + fun new(x: T): Matrix { + return {arr=[[x] * Cols] * Rows}; + } + + fun get(&self, row: Int, col: Int): &T { + return &self.arr[row][col]; + } + + fun mul( + &self, + other: &Matrix, + zero: T, + add: fun(T, T) -> T, + mul: fun(T, T) -> T + ): Matrix { + let mut result = Matrix.new(zero); + for let mut j=0; j(10); +let mut y = Matrix.new(5); + +println(x); +println(y); + +fun add_ints(a: Int, b: Int): Int = a + b; +fun mul_ints(a: Int, b: Int): Int = a * b; + +let z = y.mul<4>(&x, 0, add_ints, mul_ints); +println(z); +``` + +### Changed + +Changed type system to accommodate const generics. This was done by adding a `ConstParam` variant to types. + +### Fixed + +Improved parser speed by a significant amount during the process. \ No newline at end of file