> I'm trying to develop a library for structs (hopefully will be > generally useful), with an API parallel to the struct API. One of the > capabilities I would like to have is \typed \structs, i.e., if you > attempt to assoc something of the wrong type to a field, it throws an > error.
Following a pattern from elsewhere in Clojure, you could instead have a validating struct. Provide a validation function that is run prior to each association, either taking the new keys and values, or those and also the current struct itself. That way you can validate every key, or do more intelligent things like refuse to update an existing key, only allow :a or :b but not both, etc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---