开发者

Clojure proxy and @Override?

开发者 https://www.devze.com 2023-03-01 03:39 出处:网络
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 int

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.

0

精彩评论

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