Object-oriented languages without class concept [closed]

半腔热情 提交于 2019-12-22 02:00:15

问题


I am reading introduction to Scala paper and found following statement:

It should be noted that some object-oriented languages do not have the concept of class.

Question: Which object-oriented languages do not have class concept and how do they handle type(class) - object(type instance) relationship ?


回答1:


Although it is common in popular languages to conflate them, classes and types are different concepts. A class is properly understood as a blueprint for an object, defining the attributes and methods that instances of the class possess, but an (object) type is an interface, describing what methods can be called with what parameters.

Thus, it is not difficult to imagine languages without classes. All you need is some kind of a construct for creating objects and for giving (new) objects attributes and methods; Javascript is a well known example. Inheritance will look a bit unusual in such languages, but certainly can be done (see for example Antero Taivalsaari's article "On the notion of inheritance").



来源:https://stackoverflow.com/questions/13931524/object-oriented-languages-without-class-concept

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!