summaryrefslogtreecommitdiff
path: root/macros/core.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'macros/core.fnl')
-rw-r--r--macros/core.fnl17
1 files changed, 13 insertions, 4 deletions
diff --git a/macros/core.fnl b/macros/core.fnl
index def2f4c..df3f8b8 100644
--- a/macros/core.fnl
+++ b/macros/core.fnl
@@ -66,10 +66,13 @@
`(fn [tbl#]
(let [t# (type tbl#)]
(if (= t# :table)
- (let [(k# _#) (next tbl#)]
- (if (and (= (type k#) :number) (= k# 1)) :seq
- (= k# nil) :empty
- :table))
+ (let [meta# (getmetatable tbl#)
+ table-type# (and meta# (. meta# :cljlib/table-type))]
+ (if table-type# table-type#
+ (let [(k# _#) (next tbl#)]
+ (if (and (= (type k#) :number) (= k# 1)) :seq
+ (= k# nil) :empty
+ :table))))
:else))))
(fn seq-fn []
@@ -84,6 +87,12 @@
(insert# res# [k# v#]))
(if assoc# res# tbl#))))
+(fn& core.empty [tbl]
+ (let [table-type (table-type tbl)]
+ (if (= table-type :seq) `(setmetatable {} {:cljlib/table-type :seq})
+ (= table-type :table) `(setmetatable {} {:cljlib/table-type :table})
+ `(setmetatable {} {:cljlib/table-type (,(table-type-fn) ,tbl)}))))
+
(fn& core.into [to from]
(let [to-type (table-type to)
from-type (table-type from)]