bf74795e01
Introduces a new `RecordLayout` system for efficient and type-safe record handling. Key changes: - `RecordLayout` struct with `O(1)` field lookup using FMap optimization. - Field accessors (`.name`) are now first-class callable values. - Parser recognizes dot-prefixed identifiers as field accessors. - Binder and TypeChecker handle field accessors. - Optimizer transforms field accessor calls into specialized `GetField` nodes. - VM executes `GetField` efficiently by directly accessing record values. - Adds a new `records.myc` example showcasing record features. - Improves comparison logic for records to use pointer equality for layout.
10 lines
283 B
Plaintext
10 lines
283 B
Plaintext
;; Benchmark: 401ns
|
|
;; Benchmark-Repeat: 5016
|
|
;; Financial DSL Macro example
|
|
;; Demonstrates generating complex records from simple parameters.
|
|
;; Output: {:price 100, :size 2, :total 200}
|
|
|
|
(do
|
|
(macro trade [p s] `{:price ~p :size ~s :total (* ~p ~s)})
|
|
(trade 100 2))
|