Intrinsic types


Of course, you already understand intrinsic types such as Long, Double, and String. They contain data of the size specified by the type, and they contain built-in methods. Methods? On intrinsic types? Yes, they’re called operators. You probably don’t think of operators as methods—unless you’ve programmed in C++ or some other language that lets you redefine operators. But think about it for a minute. An operator is just a symbol that defines some standard operation for a type. Consider this statement:

iSum = iPart + 6

It’s as if the Integer type had a Plus method:

iSum = iPart.Plus(6)

In fact, in C++, an operator can use a function syntax:

iSum = iPart.operator+(6)

Operators are even polymorphic. The String, Integer, and Double types all have + operators that look the same and work in a way that intuitively looks the same, although what happens on the chip is very different for each type.


Operations on Integer and other intrinsic types are predefined. The only way to add new operations is to write procedures that have parameters of the given type. This is called functional programming, and it looks like this:

Sub SquareInteger(i As Integer)
i = i * i
End Sub

The point I want to make about intrinsic types is that the variable contains the instance data. After the expression i = 6, the variable i refers to an instance containing 6. Technically, you can make a distinction between the variable i and the instance containing 6 that i names. But nobody except me even uses the term instance when talking about intrinsic types, and I wouldn’t either if I weren’t leading up to an explanation of classes.