Env: Load lisp code at runtime from files

This commit is contained in:
Riyyi
2023-08-31 21:58:44 +02:00
parent b65482eb68
commit e8206d762c
10 changed files with 95 additions and 23 deletions
+12
View File
@@ -0,0 +1,12 @@
(defmacro! cond (fn* [& xs]
(if (> (count xs) 0)
(list 'if (first xs)
(if (> (count xs) 1)
(nth xs 1)
(throw "odd number of forms to cond"))
(cons 'cond (rest (rest xs)))))))
;; Local Variables:
;; eval: (emacs-lisp-mode)
;; End:
+14
View File
@@ -0,0 +1,14 @@
(defmacro! defmacro
(fn* [name args & body]
`(defmacro! ~name (fn* ~args (do ~@body)))))
(defmacro defn [name args & body]
`(def! ~name (fn* ~args (do ~@body))))
(defmacro def [name & body]
`(def! ~name ~@body))
;; Local Variables:
;; eval: (emacs-lisp-mode)
;; End:
+10
View File
@@ -0,0 +1,10 @@
(defn load-file [filename]
(eval (read-string (str "(do " (slurp filename) "\nnil)"))))
(defn load [filename]
(eval (read-string (str "(let* [] (do " (slurp filename) "))"))))
;; Local Variables:
;; eval: (emacs-lisp-mode)
;; End:
+6
View File
@@ -0,0 +1,6 @@
(def! *host-language* "C++")
;; Local Variables:
;; eval: (emacs-lisp-mode)
;; End:
+7
View File
@@ -0,0 +1,7 @@
(defn not [cond]
(if cond false true))
;; Local Variables:
;; eval: (emacs-lisp-mode)
;; End: