Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Can detect nil layers.

  • Loading branch information...
commit 6a423dc464080af967ce5c93a2c5850fa32beab4 1 parent a1e6c73
@eduardoejp authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/heimdallr.clj
View
9 src/heimdallr.clj
@@ -3,9 +3,10 @@
;Email: eduardoejp@gmail.com
;License: EPL 1.0 -> http://www.eclipse.org/legal/epl-v10.html
-(ns heimdallr
- "Small lib for Context-Oriented Programming."
- )
+(ns
+ #^{:author "Eduardo Emilio Julián Pereyra"
+ :doc "Small lib for Context-Oriented Programming."}
+ heimdallr)
(def #^{:doc "This dynamic var holds the current Context Stack for a thread."}
*context* (with-meta '() {:type ::ContextStack}))
@@ -69,7 +70,7 @@ The latter layers will be nested inside the former ones as in:
`(with-context ~(first ctx) (with-context ~(if (> (count (rest ctx)) 1) (vec (rest ctx)) (fnext ctx)) ~@forms))
`(let [reqs# ~ctx]
(if (or (empty? (:requires reqs#)) (->> (:requires reqs#) (map eval) (map #(some (fn [~'c] (= % ~'c)) *context*)) (every? true?)))
- (binding [*context* (conj *context* reqs#)] ~@forms)
+ (binding [*context* (if reqs# (conj *context* reqs#) *context*)] ~@forms)
(throw (Exception. (str "The layer dependencies of <" (:name reqs#) ">, " (str (:requires reqs#)) " are not active in the Context Stack.")))))
))
Please sign in to comment.
Something went wrong with that request. Please try again.