Permalink
Browse files

+ README.md

  • Loading branch information...
1 parent 1d1e091 commit a1e6c736d4f9e931779cfe21a014164cff00b25f @eduardoejp committed May 23, 2011
Showing with 51 additions and 3 deletions.
  1. +48 −0 README.md
  2. +3 −3 src/heimdallr.clj
View
@@ -0,0 +1,48 @@
+
+Heimdallr
+==========
+
+`heimdallr` is a library for Context-Oriented Programming in Clojure.
+
+Usage
+-----
+
+Simply add this to your leiningen deps: `[heimdallr "0.1.0"]`
+
+Documentation
+------------
+
+The documentation can be found here: http://eduardoejp.github.com/heimdallr/
+
+Examples
+--------
+
+ (def *employer* {:name "Q-Box Technologies"})
+ (def *person* {:name "Eduardo Julián", :employer *employer*, :address "c/ Manuel Rodriguez Objío, Santo Domingo"})
+
+ (deflayer employer-layer)
+ (deflayer address-layer)
+
+ (deflayered to-str [person] (str "Name: " (:name person) "\n"))
+ (deflayered to-str employer-layer [person] (str (proceed person) "Employer: " (:name (:employer person)) "\n"))
+ (deflayered to-str address-layer [person] (str (proceed person) "Address: " (:address person) "\n"))
+
+ (print (to-str *person*))
+
+ (with-context address-layer
+ (with-context employer-layer
+ (print (to-str *person*))))
+
+ ; The above code is the same as the following.
+
+ (with-context [address-layer employer-layer]
+ (print (to-str *person*)))
+
+Further Information
+-------------------
+
+For more information about Context-Oriented Programming, please visit the following websites:
+
+1. http://www.jot.fm/issues/issue_2008_03/article4/
+
+2. http://www.swa.hpi.uni-potsdam.de/cop/
View
@@ -7,7 +7,7 @@
"Small lib for Context-Oriented Programming."
)
-(def #^{:doc "This dynamic var holds the current ContextStack for a thread."}
+(def #^{:doc "This dynamic var holds the current Context Stack for a thread."}
*context* (with-meta '() {:type ::ContextStack}))
(def *layered-fn*)
@@ -30,7 +30,7 @@ Returns the popped layer."
(defmacro deflayer
"Defines a Layer.
-The <requires> param must be a vector of layers that are required for this layer to be executed."
+The <requires> param must be a vector of layers that are required for this layer to work."
([sym] `(def ~sym (with-meta {:name '~sym, :requires []} {:type ::Layer})))
([sym requires] `(def ~sym (with-meta {:name '~sym, :requires '~requires} {:type ::Layer})))
)
@@ -75,7 +75,7 @@ The latter layers will be nested inside the former ones as in:
(defmacro deflayered
"Defines a layered function. For the base definition, simply don't provide a layer.
-For layer dependant definitions, pass a layer before the args vector and sexps.
+For layer-dependant definitions, pass a layer before the args vector and sexps.
An optional doc-string can be provided for the base definition."
[sym & extra]
(let [ftoken (first extra)

0 comments on commit a1e6c73

Please sign in to comment.