In functional programming you can do a similar thing as in OOP: Define your
functions as closures that can access common arguments via lexical scope.
So instead of creating a context object, you create functions:
(defn make-context [some context parameters]
{:op1 (fn [x] ...)
:op2 (fn [y] ...)})
The clojure-specific variant are protocols, e.g.:
(defn make-context [some context parameters]
(reify ContextProtocol
(op1 [_ x] ...)
(op2 [_ y] ...)))
They have the advantage of better type checking + defrecords to retain
visibility into those context parameters.
Hope that helps
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.