ngrunwald / ring-middleware-format

Ring middleware for parsing parameters and emitting responses in JSON or other formats
163 stars 49 forks source link

don't use undefined :or-destructuring behavior #37

Closed MichaelBlume closed 9 years ago

MichaelBlume commented 9 years ago

The fact that one :or-param can predictably refer to another is extremely brittle -- it only works because maps in the code become PersistentArrayMaps and they have a specific seq order relative to the order keys are assoced in. With a different map implementation, or with enough keys to spill over to a PersistentHashMap, this explodes.

http://dev.clojure.org/jira/browse/CLJ-1613

jafingerhut commented 9 years ago

Michael, this looks like the kind of subtle issue that an Eastwood linter could check for automatically, but I haven't thought about it too long on how to do it yet. Is the basic recommendation you would make be: 'in an :or, no value should depend upon the values of other keys in the same :or' ?

MichaelBlume commented 9 years ago

Yeah, that makes sense, there's actually an issue open against Clojure to make it more strict about this http://dev.clojure.org/jira/browse/CLJ-1613