A newb question /+: ...
In programming, we come across the word Type frequently enough.
What should it be meant to convey, and when should it not be used?
I always learned as "A Type defines how the data is stored in memory and the actions that can be performed on it."
If you think about a class with local variables and methods, this makes sense. The instance variables define the way memory will need to be allocated for new instances, and the public methods describe the contract of actions that can be performed on instances of that class.
There are many ways to answer this question, and each way is applicable to some models, but not to others. My favorite general definition is that a type is some subset of all values in the world (for example, the type "positive integers" includes the value 1 but not the value "Stack Overflow"). Types can obviously overlap (1 could be an integer or positive integer type). This definition gives a good intuitive sense of "bigger" (more inclusive) and "smaller" types, which helps to understand covariance and contravariance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With