Fork me on GitHub
#clojure-spec
<
2020-09-09
>
borkdude19:09:43

Pushed the experiment to a repo: https://github.com/clj-kondo/inspector Contributions welcome.

borkdude19:09:37

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.

borkdude19:09:55

Non-namespaced keyword: refers to a predicate, namespaced keyword: refers to a spec

borkdude19:09:00

e.g.:

(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
borkdude19:09:43

Unambiguous:

user=> (alias 'c 'clojure.core)
nil
user=> ::c/int?
:clojure.core/int?
user=> (defn foo [^::c/int? x])

borkdude19:09:30

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 :)

borkdude19:09:39

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

borkdude20:09:35

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.

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