Fork me on GitHub
#clojure-dev
<
2015-08-11
>
arrdem19:08:37

alexmiller: http://clojure.org/java_interop 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

arrdem19:08:21

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

arrdem19:08:16

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".

arrdem19:08:21

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)

arrdem19:08:48

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

arrdem19:08:12

It isn't yet 😛

cfleming20:08:54

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

cfleming20:08:01

Which drives me nuts

arrdem20:08:50

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

arrdem20:08:59

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

cfleming20:08:52

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

cfleming20:08:59

At this point in time?