English 中文(简体)
Understanding the difference between types and representations
原标题:

This article speaks of the difference between types and classes. Since I ve only worked with languages that treat both as identical, please suggest material/programming-languages that will teach me the difference.

最佳回答

Difference is not the right word - classes are certainly types. But not all types are classes. Note also that the word "class" is quite vague - it could be just a tuple type (with no operations except construction and projection - a C struct so to speak) or, on the other side of the spectrum, a class that contains only methods, but no state.

问题回答

Sather is the oldest language i know of which treats types and classes separately. However, it is not completely rigorous, as one can still use a class as a variable type (i think), one just can t subtype it.

This is not terribly different from what C++ lets you do: you can use purely abstract classes to define types, and have all concrete classes implement them using public inheritance, but subclass each other using private inheritance. You then use the abstract classes for variable types, using the concrete classes only in constructor expressions.

Java lets you do more or less the same, defining types using interfaces and implementations using classes, but because there is no private inheritance, there is no way to hide the inheritance relationship of the classes.

Does that make any sense at all?

Java, pre-autoboxing. int and Integer are both types, but only the latter is a class.





相关问题
XML-RPC Standard and XML Data Type

I was looking at XML-RPC for a project. And correct me if I m wrong, but it seems like XML-RPC has no XML datatype. Are you supposed to pass as a string? or something else? Am I missing something? ...

Is it exists any "rss hosting" with API for creating feeds

I am creating a desktop app that will create some reports. I want to export these reports as RSS or ATOM feeds. I can easily create feeds with Rome lib for Java. But I have no idea how to spread them. ...

Improving Q-Learning

I am currently using Q-Learning to try to teach a bot how to move in a room filled with walls/obstacles. It must start in any place in the room and get to the goal state(this might be, to the tile ...

High-traffic, Highly-secure web API, what language? [closed]

If you were planning on building a high-traffic, very secure site what language would you use? For example, if you were planning on say building an authorize.net-scale site, that had to handle tons ...

Def, Void, Function?

Recently, I ve been learning different programming langages, and come across many different names to initalize a function construct. For instance, ruby and python use the def keyword, and php and ...

热门标签