Pushed the experiment to a repo: https://github.com/clj-kondo/inspector Contributions welcome.
Hmm, I realize that this is just valid Clojure syntax:
(defn foo [^:int x ^:keyword y ^:string z]
[x y z])
(prn (foo 1 2 3))
Could be a way to integrate clojure spec with existing defns without the need for writing another macro.Non-namespaced keyword: refers to a predicate, namespaced keyword: refers to a spec
e.g.:
(s/def ::s string?)
(defn foo [^:int x ^:keyword y ^:ss z]
[x y z])
we're not going to do that, but there are some other ideas percolating
Unambiguous:
user=> (alias 'c 'clojure.core)
nil
user=> ::c/int?
:clojure.core/int?
user=> (defn foo [^::c/int? x])
Bit ugly, but one of those things that could have been deemed: yeah, Rich intended it like this all along, it was all from a design originating back to 2002 ;)
except it's the opposite of what Rich intends :)
tell me more
this just plays to the familiarity from static typing langs, which is just not what Rich is trying to do with spec
This would not be limited to simple annotations. You could do:
user=> (s/def ::foo (s/keys :req-un [::x]))
:user/foo
user=> (defn f [^::foo m])
so I don't get the static typing remark.it looks like static typed function signatures, but it's not
so?
so making things that are different look the same causes confusion
there are other considerations as well - compilation, evaluation, reuse across arities, combination with other features that don't exist yet, etc
Rich is looking at all that and considering a wide variety of options including the one above
I bet
I just think this one is probably unlikely based on what I've heard