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.

alexmiller19:08:25

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

alexmiller19:08:12

arrdem: actually, I todid it at http://clojure.org/java_interop#Java%20Interop-Aliases - did you not see 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.

alexmiller19:08:46

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

alexmiller19:08:14

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

alexmiller19:08:29

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

alexmiller19:08:39

(but ^longs etc won't work)

alexmiller19:08:02

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

alexmiller19: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.

alexmiller19:08:07

I don't think that's a thing

arrdem19:08:12

It isn't yet 😛

alexmiller19:08:12

in either place :)

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.

alexmiller20: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.

alexmiller20:08:55

so, it's mostly historical afaict

alexmiller20:08:17

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

alexmiller20: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?