Fork me on GitHub
#cljs-dev
<
2018-01-23
>
bronsa16:01:17

@dnolen would you be up for a patch that unified ^ ?

bronsa16:01:38

making (defn foo ^boolean [] ..) work in cljs and soft deprecating (defn ^boolean foo [] ..)

dnolen19:01:29

well in Clojure that’s required for primitive type hints

dnolen19:01:35

I didn’t think needed in general for fn return

dnolen19:01:35

so I don’t know about deprecating, I guess the former thing should at least be made to correctly propagate type info

Alex Miller (Clojure team)20:01:30

these have different meanings(whether you’re type-hinting the var or the return type of the function) and different behavior (var meta are eval’ed, the signature meta is not). Generally type-hinting the return type (before the args vector) is the recommended and preferred place in Clojure.

mfikes20:01:15

In the AST, for (defn ^boolean foo [] ..) we end up with both :ret-tag boolean and :tag boolean. Perhaps these could somehow be detangled so that (defn foo ^boolean [] ..) affects :ret-tag

bronsa21:01:13

in cljs type hints on vars are not evaluated I believe

dnolen21:01:17

@alexmiller one difference here is that var meta is never eval’ed

dnolen21:01:24

it’s not possible

dnolen21:01:34

but point taken about the preferred way

dnolen21:01:38

we should reconcile

bronsa21:01:20

note that in clojure argvec type hints do not propagate to the var

bronsa21:01:36

(defn foo ^bar [] you won't get (:tag (meta #'foo

favila21:01:41

and what about multiple arities

favila21:01:52

also (defn foo ^boolean [] ...) in clj will throw anyway. we'd be matching style but not substance

mfikes21:01:14

@favila Interesting point about multiple arities. It reminds me that the patch in https://dev.clojure.org/jira/browse/CLJS-1997 doesn't handle that case.

favila21:01:34

does the truth_ elider understand type hints on specific arities?

favila21:01:44

if not, that's the real thing to support

favila21:01:06

and it can fall back to the var's tag metadata if missing

favila21:01:49

actually I guess there are in theory six possible things to check: arity tag, arity ret-tag, fn tag and ret-tag, and var tag and ret-tag.

favila21:01:00

not all of those exist presently though