*Edit: I have found that I am wrong about the following (as shown from the comments). In AS3, numbers are in fact placed in their wrapper classes. My interpretation are wrong. You can keep read the following if you want to know how it DOESN’T work. Basically what I describe is how Java works. AVM2 doesn’t do this, it wraps everything as an object… Sort of strange as there are performence gains using primitives.
I read a post recently that asked whether AS3 Number objects are actually treated as objects in AS3.
Number, int, etc are primitives. Just like in Java, these types have their Object class associations in case you want to create instances and call various methods that come with the Number class. For example, the Number class has functions like toFixed for number precison and accuracy.
The concept of primitives are sort of confusing to newer programming as they go against object oriented programming. In fact, in Smalltalk, one of the first OOP languages, EVERYTHING is an object. The +, -, *, etc are treated as “messages”.
In Smalltalk, since everything is an object and has messages passed, you have to specify the function for “+” and “-“. Primitives in higher level languages don’t have that just for this reason. You don’t want to have to write the code to add two numbers together do you? The concatanation syntax for Strings is also “+”. Notice how “-” is not properly handled with Strings while it is with Numbers…
Also, in terms of an ideological argument, Number can be said to be the lowest form to describe an object. Think of the composition property of object oriented design. Everything is made of objects that are made of objects that are made of objects… There are theoretically an infinite amount of layers in-between. Object oriented design is the practice of selecting certain layers and abstracting the rest. But at the very core, every object has to be made up of primatives (more specifically, since Strings can be represented as numbers). Think of any class you’ve ever programmed. The properties will always have either primatives or other objects. If you recurisvely loop through other objects they will all also be made up of primatives (unless they have no properties at all… that’s sort of an anomoly and bad programming design dependant on “isA” relationships… so I’m going to avoid that tangent).
Primitive types are the building blocks. Just like materials are made from atoms… you can’t really go lower than Numbers in describing an object. Additionally, primitives are passed by VALUE rather by reference.
Here’s another post I wrote a while back that went a little deeper into this concept.