Fork me on GitHub

Pushed the experiment to a repo: 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



(s/def ::s string?)

(defn foo [^:int x ^:keyword y ^:ss z]
  [x y z])

Alex Miller (Clojure team)19:09:43

we're not going to do that, but there are some other ideas percolating

🐟 3


user=> (alias 'c 'clojure.core)
user=> ::c/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 ;)

Alex Miller (Clojure team)19:09:14

except it's the opposite of what Rich intends :)


tell me more

Alex Miller (Clojure team)19:09:45

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=> (defn f [^::foo m])
so I don't get the static typing remark.

Alex Miller (Clojure team)20:09:57

it looks like static typed function signatures, but it's not

Alex Miller (Clojure team)20:09:24

so making things that are different look the same causes confusion

Alex Miller (Clojure team)20:09:02

there are other considerations as well - compilation, evaluation, reuse across arities, combination with other features that don't exist yet, etc

Alex Miller (Clojure team)20:09:41

Rich is looking at all that and considering a wide variety of options including the one above

👍 3
Alex Miller (Clojure team)20:09:15

I just think this one is probably unlikely based on what I've heard