I would like to suggest a functional approach as an alternative. It seems to me that the concept of "closedness" is a matter of interpretation. It could be determined by the functions manipulating the data. Sometimes you might want to treat the data (map) as closed and other times you might not care, so you just need to use the appropriate functions.
If you create your closed maps with all the allowed keys (nil values as appropriate), you just need to call contains? on any new key to make sure it's allowed. You could do that in a pre-condition. For example:
(defn assert-key [m k] {:pre [(contains? m k)]} k)
(defn assoc-closed [m k v]
(assoc m (assert-key m k) v))
(defn get-closed [m k]
(get m (assert-key m k)))
Steve Miner
steve...@gmail.com
+1