Refactor type inference for collections
The type inference for collections (tuples, vectors, matrices, and records) has been significantly refactored. This includes: - Introducing distinct `StaticType` variants for `Tuple`, `Vector`, and `Matrix`. - Implementing more robust type checking for these collections, allowing for homogeneous and heterogeneous structures. - Enhancing the `is_assignable_from` method to handle type compatibility between these collection types. - Updating `Value::static_type()` to correctly infer the types of literal collections. - Improving the type inference for map literals to create `Record` types. - Adding comprehensive unit tests for tuple, vector, matrix, and record type inference.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
;; Closure Scope Test
|
||||
;; Benchmark: 700ns
|
||||
;; Benchmark: 800ns
|
||||
;; Output: 15
|
||||
(do
|
||||
(def make-adder (fn [x]
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
;; Complex Data Structure Test
|
||||
;; Benchmark: 51.8us
|
||||
;; Benchmark: 51.4us
|
||||
;; Output: {:input 10, :name "Fibonacci", :output 55}
|
||||
(do
|
||||
(def fib (fn [n]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;; Benchmark: 300ns
|
||||
;; Benchmark: 400ns
|
||||
;; Output: 5
|
||||
(do
|
||||
(def y 1)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;; Benchmark: 400ns
|
||||
;; Benchmark: 300ns
|
||||
;; Nested Macro and Arithmetic example
|
||||
;; Output: 81
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
;; heavily recursive, benefits significantly from specialization of integer arithmetic
|
||||
;; and direct function calls (skipping dynamic dispatch).
|
||||
;; Output: 5
|
||||
|
||||
|
||||
;; Benchmark: 467.7us
|
||||
|
||||
(do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;; Benchmark: 2.8ms
|
||||
;; Benchmark: 2.7ms
|
||||
;; Output: "done"
|
||||
(do
|
||||
(def count_down (fn [n]
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
;; Benchmark: 1.9us
|
||||
;; Demonstration of N-dimensional Tuples, Vectors, and Matrices
|
||||
;; Based on docs/Tupel 1.md
|
||||
;;
|
||||
;; This test verifies that the literals are correctly parsed and represented.
|
||||
;; Type inference is verified via internal compiler unit tests.
|
||||
;;
|
||||
;; Output: [[1 3.14 "text"] [10 20 30 40] [[1 2] [3 4]] [[[1 2] [3 4]] [[5 6] [7 8]]] [[1 2] [3 4 5]] {:x 1, :y 0.3}]
|
||||
|
||||
(do
|
||||
(def tpl [1, 3.14, "text"])
|
||||
(def v [10 20 30 40])
|
||||
(def mat2d [[1 2], [3 4]])
|
||||
(def mat3d [[[1 2] [3 4]] [[5 6] [7 8]]])
|
||||
(def mixed [[1 2] [3 4 5]])
|
||||
(def rec {:x 1, :y 0.3})
|
||||
|
||||
[tpl v mat2d mat3d mixed rec]
|
||||
)
|
||||
Reference in New Issue
Block a user