Add clj fn to prelude, calls arbitrary Clojure.

This commit is contained in:
Scott Richmond 2023-06-01 12:46:52 -06:00
parent c8c74fbd49
commit a6ef6522c0
2 changed files with 14 additions and 19 deletions

View File

@ -963,11 +963,7 @@
(do (do
(def source " (def source "
let x = (1, 2)
when x is {
(y, 2) if eq (y, 1) -> :onetwo
_ -> :not_x
}
") ")
(println "") (println "")
@ -985,17 +981,3 @@
(println result) (println result)
result)) result))
(comment "
Left to do:
* improve panics
* add location info for panics
* refactor calling keywords
* refactor accessing structs vs. hashes
")

View File

@ -135,6 +135,18 @@
::data/type ::data/clj ::data/type ::data/clj
:body get-type}) :body get-type})
(defn strpart [kw] (->> kw str rest (apply str)))
(def clj {:name "clj"
::data/type ::data/clj
:body (fn [& args]
(println "Args passed: " args)
(let [called (-> args first strpart read-string eval)
fn-args (rest args)]
(println "Fn: " called)
(println "Args: " fn-args)
(apply called fn-args)))})
(def prelude { (def prelude {
"id" id "id" id
"foo" :foo "foo" :foo
@ -159,4 +171,5 @@
"get" get- "get" get-
"draw" draw "draw" draw
"type" type- "type" type-
"clj" clj
}) })