Clojure中的definterface和defprotocol之间的区别 [英] Difference between definterface and defprotocol in Clojure

查看:390
本文介绍了Clojure中的definterface和defprotocol之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了缺少文档,Clojure中的 definterface defprotocol 之间有什么区别?

Other than lack of documentation, what is the difference between definterface and defprotocol in Clojure?

推荐答案

根据Clojure的喜悦:

According to the Joy of Clojure:


使用 definterface 超过 defprotocol 的优点受限于
前者允许原始类型为
参数并返回。在将来的某个时候,同样的优势
可能会扩展到由协议生成的接口,所以使用
definterface 协议,除非绝对
必要。

The advantages of using definterface over defprotocol are restricted entirely to the fact that the former allows primitive types for arguments and returns. At some point in the future, the same advantage will likely be extended to the interfaces generated [by protocols], so use definterface sparingly and prefer protocols unless absolutely necessary.

这篇关于Clojure中的definterface和defprotocol之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆