question about resolving specs: is there a way to require a spec out of the global registry as if it were a regular var in a ns? I have discovered that I can't do something like (require [foospec.bar :refer [baz]]) presumably because baz is not interned in the foospec.bar ns but is instead in the registry? Is that correct?
correct, specs are not vars
you could put a spec in a var with (def my-spec (s/get-spec ::foo)) if you wanted to for some reason
no, not necessary, I'm fine with it being in the registry. So if require the whole foospec.bar ns say as fspec and then resolve ::fspec/baz its just looking in the registry for that fully qualified name?
that's how I have been doing it at any rate
not sure I understand "require the whole foospec.bar ns say as fspec " but fspecs are also just specs in the registry (but their keys are fully-qualified symbols, not keywords)
s/fdef just creates a spec with s/fspec, then adds it to the registry (which is just a map) with the fq symbol as the key
sorry, that was a poor choice of alias on my part
I am not talking about function specs, just any spec in general
then yes, that is how it works
@bhlieberman93 Don't forget there's :as-alias now in a require so you can create an alias for resolving Spec names without having to actually load a real namespace.
(ns using.specs
(:require [i.do-not.exist :as-alias idne]))
::idne/bar ;=> i.do-not.exist/bar
and no i/do_not/exist.clj file is needed for this.oh thanks @seancorfield I did not know about as-alias. That's helpful.