summaryrefslogtreecommitdiff
path: root/macros/core.fnl
diff options
context:
space:
mode:
authorAndrey Orst <andreyorst@gmail.com>2020-10-27 22:11:27 +0300
committerAndrey Orst <andreyorst@gmail.com>2020-10-27 22:19:43 +0300
commit1445ceaa9d13a9340a65624278f8df27dcf3c6fe (patch)
treece4c897e018e1a3c89c99ae03593e05c6857261f /macros/core.fnl
parent4288f1f60c7445dd42e2e93b3d5cf5700d3dcec8 (diff)
feature(core): implement auto namespacing for fn* and create fn&
Redefining everything in terms of fn* and fn* breaks coverage.sh
Diffstat (limited to 'macros/core.fnl')
-rw-r--r--macros/core.fnl20
1 files changed, 8 insertions, 12 deletions
diff --git a/macros/core.fnl b/macros/core.fnl
index ed147ed..c954f77 100644
--- a/macros/core.fnl
+++ b/macros/core.fnl
@@ -1,4 +1,5 @@
-(import-macros {: fn*} :macros.fn)
+(import-macros {: fn* : fn&} :macros.fn)
+(local core {})
(local unpack (or table.unpack _G.unpack))
(local insert table.insert)
@@ -6,7 +7,7 @@
(and (assert-compile (sequence? bindings) "expected binding table" [])
(assert-compile (= (length bindings) 2) "expected exactly two forms in binding vector." bindings)))
-(fn* if-let
+(fn* core.if-let
([bindings then]
(if-let bindings then nil))
([bindings then else]
@@ -18,7 +19,7 @@
,then)
,else)))))
-(fn* when-let
+(fn* core.when-let
[bindings & body]
(-check-bindings bindings)
(let [[form test] bindings]
@@ -27,7 +28,7 @@
(let [,form tmp#]
,(unpack body))))))
-(fn* if-some
+(fn* core.if-some
([bindings then]
(if-some bindings then nil))
([bindings then else]
@@ -39,7 +40,7 @@
(let [,form tmp#]
,then))))))
-(fn* when-some
+(fn* core.when-some
[bindings & body]
(-check-bindings bindings)
(let [[form test] bindings]
@@ -56,7 +57,7 @@
:else))
;; based on `seq' from `core.fnl'
-(fn into [to from]
+(fn& core.into [to from]
(local to-type (-table-type to))
(local from-type (-table-type from))
`(let [to# ,to
@@ -106,9 +107,4 @@
:else (error "expected table as first argument"))
to#))
-
-{: if-let
- : when-let
- : if-some
- : when-some
- : into}
+core