Fork me on GitHub

@alexmiller can you share rationale behind decision to limit spec names to keywords? (and symbols, right? for fdefs...)


I believe, it's more like: spec allows us to spec data and functions. We spec functions by their name and pieces of data by their name (keywords), symbols are already used to name vars in the context of the language, which is why symbols can't be used. All other stuff (strings, characters, aggregates, etc) is not namespace qualified and hence those cannot be "precise" names. That causes collisions and is a recipe for brittleness IMHO.


@vlaaad: Though I’m asking whether it’s possible or suggestions on how to do it; I totally understand the reason to name specs with keywords. I suspect the main reason is that they support namespaces; and can therefore be unambiguous and named in a global context, but don’t require a dependency on being loaded like vars. Allowing the use of a key to be decoupled from its spec/definition, whilst also allowing the same key to have multiple specs. Like with RDF it means it’s open for extension, anyone can spec anything etc. The reason I’d like to do it, is because when I convert RDF into a clojure structure, it’d be nice not to have too coerce URI’s (which are used to identify properties & classes in the same way spec uses keywords) into keywords. However it’s probably not so bad, maintaining that mapping. I was just hoping it’d be possible to write my own version of s/keys that used URI’s directly.


it's super easy to make your own in the meantime. Just use atom as metadata registry + write few fns (alter-meta, doc, meta, etc). then it's possible to chain (-> (s/def ::foo string?) (stg/with-doc "bla bla bla")) since specs returns their key.


I'm trying to create a spec around a time characterstic in a cljc file and getting confused. I generally try to use tick to manage time within cljs and clj. But their api doesn't have any tests for type of time that I'd like to put into the spec. What do others do for cljc spec that involve times?


Does inst? work?