It seems however that the consensus of the group based on what I've
said so far is to pass around state in a structmap.

Not necessarily a struct-map. Just a map.

This is nice in
that it makes each function completely self contained (e.g. no
external references). It's unfortunate in that it now means that every
single function needs this extra argument and every variable access
either needs to use the :keys feature in the arguments or has to
directly refer to the keys in the map.

Not necessarily. At some point your functions should be fine-grained enough that they only take a couple of arguments. As soon as you drop below 6 or 7, where they're all mandatory, switch to ordinary function argument style.

Wherever you call those functions should do the unpacking.

E.g.,

(defn outer-1 [{:keys [foo bar baz noo]}]
  (let [interm (foo-bar foo bar)
        fiddle (frostrup baz noo)]
    (tweep interm fiddle)))

After all, your house-sale-profit function should be expressed in terms of two arguments:

(defn house-sale-profit [house-sale-price house-sale-expenses]
  ...)

It doesn't care about the other 17.

Another thing: that big entry point function is like a much tidier version of the Java constructor that you created with 19 arguments -- tidier in that you can use named keys or a map to identify the arguments.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to