In Java when you wa开发者_开发百科nt to override something you use @Override sometimes. How can you do the same in a Clojure proxy?
Every method in a proxy should override a superclass method or an interface method, so it's a slightly different situation from a Java class where you can add new methods. So, if Clojure offered a way to mark proxy methods as overrides, then all valid proxies would have that annotation for each method.
Unfortunately, Clojure will let you define a method in a proxy that does not belong to any of the classes or interfaces that the proxy overrides. That method will not be callable or accessible in normal usage, however.
精彩评论