Fork me on GitHub

alexmiller: doesn't mention ^"" or the equivalent #^"" classname hints for arrays and other types. Just had a heck of a time finding out that was a feature.

Alex Miller (Clojure team)19:08:25

arrdem: yeah, I've got an old todo to fix exactly that


alexmiller: > long arrays (long-array []) have a type of "[J". is intended to be interpreted as ^"[J" will work?


I read that as "here's a list of the special case symbols for things you can't reasonably hint", not "you have this string escape hatch and here's some helpers".


but maybe that's me.

Alex Miller (Clojure team)19:08:46

no, don't think so - that would be ^(Class/forName "[J") wouldn't it?

Alex Miller (Clojure team)19:08:14

the other aspect is that it matters whether you are talking about on a var vs param/return of a defn

Alex Miller (Clojure team)19:08:29

var meta hints are evaluated so you can do stuff like that

Alex Miller (Clojure team)19:08:39

(but ^longs etc won't work)

Alex Miller (Clojure team)19:08:02

in a defn however they are not evaluated and things like ^longs will work

Alex Miller (Clojure team)19:08:12

(I'm going from memory, so this could be off)


I'll trust you, don't have a REPL handy. Was trying to make ^[T] for T a legal type alias work.

Alex Miller (Clojure team)19:08:07

I don't think that's a thing


It isn't yet 😛


@alexmiller @arrdem: Also, generally type hints on fn args generally have to be fully qualified, and not on var meta hints


Which drives me nuts


Is there a reason why var hints are treated specially and evaluated? This seems like a "pick one and stand by it" case.


I don't argue that it's useful, just odd to have both.

Alex Miller (Clojure team)20:08:46

I actually talked to Rich about this the other day and he said there was a point in time where a decision needed to be made on this and a fork in the road was chosen. It was unclear at the time how they would be used.

Alex Miller (Clojure team)20:08:55

so, it's mostly historical afaict

Alex Miller (Clojure team)20:08:17

and probably difficult to change either now w/o breaking things

Alex Miller (Clojure team)20:08:01

yeah, as soon as Java gets there we'll think about that :)


@alexmiller: If a fork in the road were to be taken, would it be for evaluating hints or not evaluating them?


At this point in time?