Clojure - How do I check for prompt types in protocols?

How to check if the type hints that I put in my code are specified correctly?

It seems that even if I put the wrong hints, it works without any warnings:

=> (defprotocol Qqq (^Qwerty qqq [this ^String q]))
Qqq
=> (qqq (reify Qqq (qqq [this q] (+ q 5))) 7)
12
+3
source share
1 answer

As I recall, tooltip types are no longer used, but can be used in the future ... Here is a link from the official description on clojure.org


Fields

can have types of hints and can be primitive:

  • note that at present, the type of hint of a non-primitive type will not be used to limit the type of a field or constructor arg, but will be used to optimize its use in class methods.
  • arg and constructor type constraint planned
+4
source

Source: https://habr.com/ru/post/1790707/


All Articles