patternMinor
What does Harper mean by "class"?
Viewed 0 times
whatmeandoesclassharper
Problem
I've been teaching myself type theory on and off over the past couple years. I've reach large sections of Pierce's Types and Programming Languages and Harper's Practical Foundations for Programming Languages, but there are still sections I need to either read for the first time or really understand.
In Harper's section on classes, this is his introduction:
It frequently arises that the values of atype are partitioned into a variety of classes, each classifying data with distinct internal structure. A good example is provided by the type of points in the plane, which may be classified according to whether they are represented in cartesian or polar form. Both are represented by a pair of real numbers, but in the cartesian case these are the x and y coordinates of the point, whereas in the polar case these are its distance, r, from the origin and its angle, θ, with the polar axis. A classified value is said to be an object, or instance, of its class. The class determines the type of the classified data, which is called the instance type of the class. The classified data itself is called the instance data of the object.
As far as I can tell, this does not align closely with objects as they are commonly understood in programming languages today. When I think of classes, I think primarily of encapsulation and inheritance, not of classifying different representations of a value.
Am I right in believing this is not the same definition of classes that is commonly used? Is this definition common in the academic community? Are there any programming languages where these kinds of classes are used?
Update
Since this question seems to have attracted some recent activity, I'll update with my current understanding.
We start with the general, abstract notion of a two-dimensional table. Each cell in the table specifies a function acting on a specified type. Thus, the rows are "classes" and the columns "methods" with dynamic dispatch.
If we take the row-oriented view, t
In Harper's section on classes, this is his introduction:
It frequently arises that the values of atype are partitioned into a variety of classes, each classifying data with distinct internal structure. A good example is provided by the type of points in the plane, which may be classified according to whether they are represented in cartesian or polar form. Both are represented by a pair of real numbers, but in the cartesian case these are the x and y coordinates of the point, whereas in the polar case these are its distance, r, from the origin and its angle, θ, with the polar axis. A classified value is said to be an object, or instance, of its class. The class determines the type of the classified data, which is called the instance type of the class. The classified data itself is called the instance data of the object.
As far as I can tell, this does not align closely with objects as they are commonly understood in programming languages today. When I think of classes, I think primarily of encapsulation and inheritance, not of classifying different representations of a value.
Am I right in believing this is not the same definition of classes that is commonly used? Is this definition common in the academic community? Are there any programming languages where these kinds of classes are used?
Update
Since this question seems to have attracted some recent activity, I'll update with my current understanding.
We start with the general, abstract notion of a two-dimensional table. Each cell in the table specifies a function acting on a specified type. Thus, the rows are "classes" and the columns "methods" with dynamic dispatch.
If we take the row-oriented view, t
Solution
The term class here has absolutely nothing to do with OOP classes. Rather, a class determines which possibility in a C
For example, one definition of a binary tree is: a binary tree is either a leaf or a pair of binary trees. Leaves form one (boring) class, pairs of binary trees form another.
Mathematical terminology often uses words which have other meanings in common usage. You should get used to that.
union an object takes.For example, one definition of a binary tree is: a binary tree is either a leaf or a pair of binary trees. Leaves form one (boring) class, pairs of binary trees form another.
Mathematical terminology often uses words which have other meanings in common usage. You should get used to that.
Context
StackExchange Computer Science Q#52566, answer score: 2
Revisions (0)
No revisions yet.