94fc6bf56d
This commit introduces support for AST macros and templates, enabling users to define and use custom, reusable components within the visual DSL. Key changes include: - A new `MacroRegistry` to manage macro definitions. - A `MacroExpander` to process macro calls and expand templates. - A `MacroEvaluator` trait for evaluating expressions during expansion. - The `Expansion` node in `BoundKind` to preserve the original macro call and its expanded form for debugging. - Updates to the `Binder`, `Dumper`, and `UpvalueAnalyzer` to handle the new macro constructs. - New examples demonstrating various macro functionalities like `unless`, splicing, and nested macros.
27 lines
730 B
Plaintext
27 lines
730 B
Plaintext
;; Benchmark: 1.5us
|
|
;; Output: 36
|
|
(do
|
|
;; Excessive capture test
|
|
;; This script creates deep nesting where the inner-most lambda
|
|
;; grabs variables from every single outer scope.
|
|
|
|
(def excessive (fn [v1]
|
|
(do
|
|
(def v2 2)
|
|
(fn [v3]
|
|
(do
|
|
(def v4 4)
|
|
(fn [v5]
|
|
(do
|
|
(def v6 6)
|
|
(fn [v7]
|
|
(do
|
|
(def v8 8)
|
|
;; v1, v3, v5, v7 are parameters (captured as upvalues)
|
|
;; v2, v4, v6, v8 are locals (captured from outer scopes)
|
|
(+ v1 v2 v3 v4 v5 v6 v7 v8))))))))))
|
|
|
|
;; Execution: (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8) = 36
|
|
((((excessive 1) 3) 5) 7)
|
|
)
|