Fork me on GitHub
#clojure-dev
<
2016-06-30
>
niwinz11:06:25

Hi, I'm not clearly understand why a clojure.core (in same way as clojure.string) uses wrong location (before var) for type hints where the http://clojure.org/reference/java_interop#typehints says that the type hints should go before arguments vector. Is the documentation outdated?

bronsa11:06:50

@niwinz: it's not wrong location. it's and "outdated" (not really deprecated although I wish it was) way of type-hinting

bronsa11:06:28

it's strictly less expressive and more problematic than typehinting on argvecs

niwinz11:06:42

seems like type hints on argsvec are also problematic...

niwinz11:06:40

In fact, @alexmiller says in that thread that typehints on var are invalid position... but clojure has a bunch of typehints on supposedly invalid location

niwinz11:06:18

I'm missing something or this is really confusing...

Alex Miller (Clojure team)11:06:01

No, it's really confusing :)

niwinz11:06:18

On the end, using typehints in var is valid or invalid?

bronsa11:06:04

@niwinz: type hints on argvecs are not problematic anymore since 1.7 or 1.8 can't remember

bronsa11:06:37

1.8 apparently

bronsa11:06:53

if you're using <1.8.. then it's confusing. if you're using >=1.8, just put the type hints on the argvec and it's going to do what you mean to do (assuming you're using the correct type hint obviously :) )

niwinz11:06:27

@bronsa: you are right, I found very strange errors when using typehints on argsvec but in 1.8 they does not happens

anmonteiro11:06:48

@bronsa: what about functions with multi-arity?

anmonteiro12:06:02

Repeat the type hint on each argvec or put it on the var?

bronsa12:06:05

type hint every argvec ¯\(ツ)

bronsa12:06:27

I mean, there are cases where type hinting the Var is ok. But I'd rather have some repetition if that avoids nasty and undocumented edge cases