weavejester / reagi

An FRP library for Clojure and ClojureScript
232 stars 13 forks source link

Added def-behave->, def-behave->>, and documentation #1

Closed runexec closed 11 years ago

runexec commented 11 years ago

def-behave-> and def-behave->>

user> (r/def-behave-> b a inc)
#'user/b
user> @b
2
user> (swap! a dec)
0
user> @b
1
user> (r/def-behave->> b a (str "a = "))
#'user/b
user> @b
"a = 0"
weavejester commented 11 years ago

These macros are rather too specific in what they do. Macros that add syntax sugar should be used sparingly, as they trade brevity for complexity, which is almost always not worth the trouble.

runexec commented 11 years ago

How about a def-behave that just does (def ~-symbol (behavioir ~@body)) ?

weavejester commented 11 years ago

That's better, but still too specific. Clojure doesn't have def-atom or def-agent; it's sufficient just to have def and atom or def and agent.

Another big problem with overusing def* macros is that it implies something magical is going on. Often I regret adding defroutes to Compojure, because it obscures the meaning of the routes function.

runexec commented 11 years ago

Those are some very good points. I'll see what else I can come up with. Thanks for the input and the speedy responses.