This commit is contained in:
2026-06-08 13:21:57 +02:00
parent 823130e3ac
commit 8bee76328b
23 changed files with 734 additions and 382 deletions
+11 -8
View File
@@ -2,12 +2,15 @@
(require "../main.rkt")
;; There is no separate optimizer in js-maker 3. This demo shows the compact
;; named-let loop output produced directly by the `js` macro.
;; js-maker 3 does not have a separate optimizer pass. The notable direct
;; lowering is named let to a while(true) loop with parallel updates.
(define optimized-example
(js
(define (sumTo n)
(let loop ([i 0] [acc 0])
(if (> i n)
(return acc)
(loop (+ i 1) (+ acc i)))))))
(module+ main
(display
(js (define (factorial n)
(let loop ([i n] [acc 1])
(if (<= i 1)
(return acc)
(loop (- i 1) (* acc i))))))))
(displayln optimized-example))