proxy-plus icon indicating copy to clipboard operation
proxy-plus copied to clipboard

Ergonomic Hints

Open owenRiddy opened this issue 1 year ago • 0 comments

It can be frustrating to work out what type signatures are available. It'd be helpful to include a list of options on errors (demo: https://github.com/owenRiddy/proxy-plus-minus/blob/main/src/proxy_plus_minus/core.clj#L122).

What this looks like using the proposed custom hinting from Issue #20 :

          (proxy+ [] TestBaseClass3
                  (trickyCase [this a b] [char java.lang.String :=> int] 8))
=>
Caused by: clojure.lang.ExceptionInfo: No matching methods {:base testclasses.TestBaseClass3, 
:name "trickyCase", 
:param-type [char java.lang.String :=> int],
 :param-type-options (["finalize" [:=> void]] ["clone" [:=> java.lang.Object]] 
["getInt" [:=> java.lang.Integer]] ["getDouble" [int double java.lang.String java.lang.Integer boolean :=> double]] 
["getString" [java.lang.String :=> java.lang.String]] ["getOtherInt" [:=> int]] 
["trickyCase" [int java.lang.String :=> int]] ["trickyCase" [java.lang.Integer java.lang.String :=> int]] 
["wait" [long int :=> void]] 
["wait" [:=> void]] ["wait" [long :=> void]] ["equals" [java.lang.Object :=> boolean]] 
["toString" [:=> java.lang.String]] ["hashCode" [:=> int]] ["getClass" [:=> java.lang.Class]]
 ["notify" [:=> void]]
 ["notifyAll" [:=> void]])}

;; Programmer thinks: 'Aha! I want ["trickyCase" [int java.lang.String :=> int]] 
;;       so I should use [int java.lang.String :=> int]'

owenRiddy avatar Sep 07 '23 11:09 owenRiddy