-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcore.ss
18 lines (18 loc) · 1.07 KB
/
core.ss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(core-define "define" (core-macro ("name" "value")
(cons2 (symbol "core-define")
(cons (str name) value))))
(define set (core-macro ("name" "value")
(cons2 (symbol "core-set")
(cons (str name) value))))
(define println (core-lambda (quote ("value")) (quote (do (display value) (newline)))))
(define print display)
(define all-sym-to-str (core-lambda (quote ("items")) (quote (map sym->str items))))
(define lambda (core-macro ("params" "body") (do (core-set "params" (all-sym-to-str params)) (core-lambda params body))))
(define macro (core-macro ("params" "body") (do (core-set "params" (all-sym-to-str params))
(realize (cons2 (symbol "core-macro") (cons params body)))
)))
(define defmacro (macro (name params body) (do
(cons2 (symbol "define") (cons name (cons2 (symbol "macro") (cons params body))))
)))
(defmacro defn (name params body)
(realize (list (symbol "define") name (list (symbol "lambda") params body))))