|
|
|
|
|
by dmichulke
1220 days ago
|
|
Eventually you want non-developers to develop business rules, so you come up with pseude-code like when X then do Y
You can write them in Clojure like in the above example: [:rule [:when X] [:then Y]]
which is kind of self-explanatory. X and Y can be any valid predefined expressions, e.g. [:rule [:when [:< amount 100]] [:then [:send-email-to-boss]]]
If you had such a rule, you'd just parse that line as edn, substitute all symbols (check for injection attacks) and execute it.However, effectively clojure itself is most often the smallest representation: (when (< amount 100) (send-email-to-boss))
It's just not that readable because it's missing the "then", but it would be valid clojure right away.In the end it's like a code snippet that non-developers can write without having to set up a compiler, run-time, syntax-checker |
|