有多少个 oo 功能杂种?
我们在这里讨论 oo 功能混合体,但我想知道有多少种语言实际上符合这个名称。 Scala、Clojure、F#?还有吗?
如果每个答案都能得到一种这样的语言,并且有一点解释,为什么你认为它是 oo 功能混合体,那就太好了。
We're discussing oo-functional hybrids here, but I wonder, how many languages actually qualify for this name. Scala, Clojure, F#? Any more?
It'd be great to get one such language per answer, and a little explanation, why you think it is oo-functional hybrid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
Objective Caml - 与 ML 系列中的任何语言一样功能强大,但顾名思义,它还拥有一个完善的(并且有些独特 - 我所知道的唯一完全结构化的)OO 系统。
Objective Caml - as functional as any language from ML family is, but as the name implies, also has a well-developed (and somewhat unique - the only fully structural one I'm aware of) OO system.
通用 Lisp。功能方面是相当明显的,另一方面,CLOS 是所有对象模型之母。
Common Lisp. The functional aspects are quite evident, and, on the other hand, CLOS is the mother of all object models.
闲聊。我相信很多人会不同意,但我认为该语言不仅拥有一流的函数,而且大量使用它们,甚至最基本的构造(例如 if/else 和循环)也被实现为函数调用-type 参数,值得贴上“函数式”标签。此外,你列出了Ruby,它在FP部分的大部分内容都是从Smalltalk继承的。
Smalltalk. I'm sure many will disagree, but I think that the language that not only had first-class functions, but used them so heavily that even the most fundamental constructs (such as if/else and loops) were implemented as function calls taking function-type arguments, deserves the label "functional". Besides, you list Ruby, and most of what it has in FP department, it inherited from Smalltalk.
Nemerle(不幸的是)并不是广为人知的设计用于在 .NET 平台上运行的函数式面向对象混合体。 Nemerle 的有趣之处在于它的多功能宏系统和强大的类型推断。
Nemerle is (unfortunately) not so widely known functional-OO hybrid designed to run on the .NET platform. What makes Nemerle interesting is its versatile macro system and powerful type inference.
O'Haskell,它基本上是一个具有面向对象功能的 Haskell栓上。
O'Haskell, which is basically a Haskell with object-oriented features bolted on.
Racket 是一种具有类系统的函数式语言(Scheme 的方言)。类系统支持可重写方法(如 Java、C#)和可扩展方法(超类的方法首先获得控制;它决定是否/何时调用子类的方法以及如何处理结果)。类系统还支持高阶合约。
实际上,Lisps 和Schemes 有很多对象系统。 Common Lisp 的 CLOS 可能是最著名和最有影响力的。
Racket is a functional language (a dialect of Scheme) with an class system. The class system supports both overridable methods (like Java, C#) and augmentable methods (the superclass's method gets control first; it decides if/when to call the subclass's method and what to do with the result). The class system also supports higher-order contracts.
Actually, there are many object systems for Lisps and Schemes. CLOS for Common Lisp is probably the most famous and influential.