I should be straightforward to implement a closed map (or record)
yourself using deftype. It could implement all the same interfaces as
Clojure's built-in maps, ensuring compatibility with assoc and such.
Here's an example of a map variant implemented using deftype:

https://github.com/clojure/clojure-contrib/blob/master/modules/priority-map/src/main/clojure/clojure/contrib/priority_map.clj

Justin

On Apr 22, 1:44 am, Christian Schuhegger
<christian.schuheg...@gmail.com> wrote:
> I am taking up a discussion from 
> 2010:https://groups.google.com/group/clojure/browse_frm/thread/60dff89149c...
>
> I would prefer if it would be possible to define "closed maps", e.g.
> maps that allow only a certain set of keywords, both for get and
> "set" (like in assoc, assoc-in, update-in, ...). It would be nice if
> there would be an option on defrecord to mark the map as "closed".
>
> I imagine that this would have some runtime penalty, because for every
> access it has to be verified if the key is a valid one. I understand
> that. Perhaps in that case the language could react differently based
> on the value of a dynamic var (*check-closed-defrecrod-p*) that can be
> set when the unit tests are run and could be false by default.
>
> I guess this topic was already discussed several times. Could somebody
> point me to previous discussions and their outcome?
> I've found in addition the following thread where the idea of "safe
> maps" was discussed to some 
> extent:https://groups.google.com/group/clojure/browse_frm/thread/134642cc76d...
>
> Thanks,
> Christian

-- 
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