jolt/.calva/repl.calva-repl
Dmitri Sotnikov d3194aae59
Compiler research (#10)
adds self-hosted compiler is functionally:
 
- The default compile path is the portable pipeline using jolt.analyzer (Clojure) → host-neutral IR → backend.janet.
- The analyzer is itself Clojure, compiled by jolt for true self-hosting.
- bootstrap-fixpoint passes (stage1 == stage2 == stage3): rebuilding the compiler on its own output.
- clojure.core is now self-hosted in the overlay.
- Stateful forms (defmacro/ns/deftype/defmulti/require/in-ns) are interpreted by design.
2026-06-09 07:30:25 +08:00

43 lines
980 B
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(when-let [requires (resolve 'clojure.main/repl-requires)] (clojure.core/apply clojure.core/require @requires))
cljuser> 
(defn read
[reader]
(let [line ((get (dyn :current-env) (symbol "file/read")) reader :line)]
(when line
(read-string line))))
cljuser> 
(defn foo [])
cljuser> 
(foo)
cljuser> 
(defn foo [x]
(into (range 10) [x]))
cljuser> 
(foo)
; expected integer key for tuple in range [0, 0), got 0
cljuser> 
(foo 10)
cljuser> 
(foo "a")
cljuser> 
(foo :a)
cljuser> 
(sh "ls")
; Unable to resolve symbol: sh
cljuser> 
(jolt/sh "ls")
; Unable to resolve symbol: jolt/sh
cljuser> 
(defn sh
[& args]
(let [cmd (apply str (interpose " " args))
result (os/shell cmd)]
{:exit (result 0) :out (result 1) :err (result 2)}))
cljuser> 
(defn shell
[& args]
(:out (apply sh args)))
cljuser> 
(sh "ls")
; Unable to resolve symbol: os/shell
cljuser>