类型擦除如何帮助 Clojure 存在?
JVM 类型擦除对 Clojure 有什么帮助?没有它,Clojure 还能存在吗?如果 JVM 具有具体化类型会发生什么?也就是说,Clojure 将如何改变?
How does JVM type erasure help Clojure? Can Clojure exist without it? What would happen if the JVM had reified types? That is, how would Clojure change?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Clojure 根本不会改变太多。类型擦除仅适用于 Java 的泛型类型参数。所有其他类型都在运行时可用。
浏览一下 Clojure 的源码,它根本没有太多使用泛型。在运行时中,它传递
Object
并执行instanceof
检查。通过将所有内容视为对象
,它不需要泛型,因此不需要删除任何类型参数。Clojure wouldn't change much at all. Type erasure only applies to Java's type-parameters for generics. All other types are available at runtime.
Browsing Clojure's source, it does not use generics much at all. In the runtime, it passes around
Object
s and doesinstanceof
checks. By treating everything as anObject
, it has no need for generics, and thus, there are no type-parameters to be erased.据我所知,Clojure 不使用 JVM 的类型擦除,所以我认为如果没有它,不会有太大变化。
From what I can tell Clojure does not use type erasure from the JVM, so i dont think much would change with out it.