开发者

Clojure - How to check if type hints in protocols are correct?

开发者 https://www.devze.com 2023-02-09 10:38 出处:网络
How to chec开发者_如何学Ck if I the type hints I have put to my code are correct? It seems like even if I put wrong type hints it works without any warnings:

How to chec开发者_如何学Ck if I the type hints I have put to my code are correct?

It seems like even if I put wrong type hints it works without any warnings:

=> (defprotocol Qqq (^Qwerty qqq [this ^String q]))
Qqq
=> (qqq (reify Qqq (qqq [this q] (+ q 5))) 7)
12


As I remember, type hints aren't used right now, but could be used in future... Here is cite from official description at clojure.org


fields can have type hints, and can be primitive:

  • note that currently a type hint of a non-primitive type will not be used to constrain the field type nor the constructor arg, but will be used to optimize its use in the class methods
  • constraining the field type and constructor arg is planned
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号