Tag Info

New answers tagged

3

The problem I am trying to solve is, given two types, how can I determine whether one can be converted to the other. In your language design, you have a well defined set of rules for your type system. A is a subtype of B if and only if these conditions hold. C can be assigned to a variable of type D if and only if these other conditions hold. And you ...


4

Algebraic data types are the way to discuss this. There are three fundamental ways you can combine types: Product. That's basically what you're thinking of: struct IntXDouble{ int a; double b; } is a product type; its values are all possible combinations (i.e. tuples) of one int and one double. If you consider the number types as sets, then the ...


5

Types are not sets. You see, set theory has a number of features which simply don't apply to types, and vice-versa. For instance, an object has a single canonical type. It may be an instance of several different types, but only one of those types was used to instantiate it. Set theory has no notion of "canonical" sets. Set theory allows you to create ...


2

A type is a description of a category/range of values, compound structures, or what have you. OOPwise, it is akin to an "interface". (In the language-agnostic sense. The language-specific sense, not so much. In Java, for example, int is a type, but has no relation to an interface. Public/protected field specifications, as well, are not part of an ...


2

Sorry but I don't know about the "raw" theory. I can only provide a practical approach. I hope this is acceptable at programmers.SE; I'm not familiar with the etiquette here. A central theme of OOP is information hiding. What the data members of a class are, exactly, should be of no interest to its clients. A client sends messages to (calls methods / ...


30

Neither. I take it you're asking whether having the same set of field types is enough to classify as being the same class, or whether they have to be named identically as well. The answer is: "Not even having the same types and the same names is sufficient!" Structurally equivalent classes are not necessarily type-compatible. For instance, if you have a ...



Top 50 recent answers are included