Object-oriented languages without class concept [c

2019-04-19 06:11发布

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条回答
趁早两清
2楼-- · 2019-04-19 07:14

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").

查看更多
登录 后发表回答