Skip to content

Commit

Permalink
datascript.shim → datascript.arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Sep 19, 2015
1 parent 31793ab commit dcd0d9e
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 230 deletions.
15 changes: 11 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# WIP

- [ BREAKING ] **Main namespace to include is now `datascript.core`**, not `datascript`.
- **[ BREAKING ] Main namespace to include is now `datascript.core`, not `datascript`**
- [ BREAKING ] Old `datascript.core` (internal namespace) was renamed to `datascript.db`
- [ BREAKING ] `datascript.shim` (internal namespace) was renamed to `datascript.arrays`

Motivation: Usage of top-level namespaces is discouraged and even generates a warning in CLJS. This would’ve happen sooner or later anyways. 0.13 seems like a great number for this sort of release.
Motivations:

Migration path: just change `(require '[datascript :as d])` to `(require '[datascript.core :as d])` and you’re good to go.
- Usage of top-level namespaces is discouraged and even generates a warning in CLJS.
- Better sooner than later.
- 0.13 seems like a great number for this sort of release.

Due to significance and impact of this release (100% user base), there’re no other changes in this release.
Migration procedure:

- Just change `(require '[datascript :as d])` to `(require '[datascript.core :as d])` and you’re good to go.

For the sake of easy migration, there’re no other changes in this release. Just renamings.

# 0.12.2

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Check out [test/js/tests.js](test/js/tests.js) for usage examples.

## Project status

Alpha quality. Half of the features done, a lot of cases where error reporting is missing, no docs (use examples & Datomic documentation).
Beta quality. Most of the features done, expecting some API polishing (breaking) and performance optimizations. No docs at the moment, use examples & Datomic documentation.

The following features are supported:

Expand Down
41 changes: 6 additions & 35 deletions src/datascript/shim.cljc → src/datascript/arrays.cljc
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
(ns datascript.shim
(ns datascript.arrays
(:require
[clojure.string :as str])
(:refer-clojure :exclude [make-array into-array array amap aget aset alength array? seqable? aclone])
#?(:cljs (:require-macros datascript.shim))
(:refer-clojure :exclude [make-array into-array array amap aget aset alength array? aclone])
#?(:cljs (:require-macros datascript.arrays))
#?(:clj (:import [java.util Arrays])))

(defn- if-cljs [env then else]
(if (:ns env) then else))

#?(:cljs (def make-array cljs.core/make-array)
:clj (defn make-array ^{:tag "[[Ljava.lang.Object;"}
[size]
Expand All @@ -15,9 +18,6 @@
[aseq]
(clojure.core/into-array java.lang.Object aseq)))

(defn- if-cljs [env then else]
(if (:ns env) then else))

#?(:clj
(defmacro aget [arr i]
(if-cljs &env
Expand Down Expand Up @@ -83,32 +83,3 @@
(def array?
#?(:cljs cljs.core/array?
:clj (fn array? [^Object x] (-> x .getClass .isArray))))

(def seqable?
#?(:cljs cljs.core/seqable?
:clj (fn seqable? [x]
(or (seq? x)
(instance? clojure.lang.Seqable x)
(nil? x)
(instance? Iterable x)
(array? x)
(string? x)
(instance? java.util.Map x)))))

(def neg-number? (every-pred number? neg?))

#?(:clj
(defmacro half [x]
`(unsigned-bit-shift-right ~x 1)))

#?(:clj
(defmacro not== [x y]
`(not (== ~x ~y))))

(defn zip
([a b] (map vector a b))
([a b & rest] (apply map vector a b rest)))

(defn has? [coll el]
(some #(= el %) coll))

Loading

0 comments on commit dcd0d9e

Please sign in to comment.