Quote Originally Posted by savage
Hi Sly,
The decision to go with classes was a conscious one. I am aware that records are more compact and quicker using traditional methods, but I wanted to use classes for clarity and not speed. The idea being that once their game/engine is up and running they can look into where the bottlenecks are then remove them, ie rewrite their Vector handling for example.
I think having vectors as a class will reduce clarity as well as speed. You will spend more time managing the creation and destruction of TVector instances than using the vectors to do useful things, let alone tracking down lost memory because you forgot to free some vectors somewhere.

Another downside to using classes is memory fragmentation. You will be doing potentially tens or hundreds of thousands of tiny memory allocations and deallocations that is going to cause heartache for the standard Borland memory manager. Some of the replacement memory managers at http://www.fastcode.dk will handle it better, but that's a dependency on a third-party library.

Just on the class size/speed issue, would it be better to use Object Pascal's "object" keyword instead for these kind of objects. Does anyone have any info on how much better this performs over classes?
Using 'object' instead of 'class' could eliminate a lot of the shortcomings of classes that I mentioned. From the Delphi help: "Since object types do not descend from TObject, they provide no built-in constructors, destructors, or other methods. You can create instances of an object type using the New procedure and destroy them with the Dispose procedure, or you can simply declare variables of an object type, just as you would with records." It also mentions that 'object' is supported for backwards compatibility only and should not be used.

In the case of returning a new instance of a class, what would be a better way of implementing this? Should it just change the current vector, thus leaving it up to the developer using the class to handle storing/restoring the vector as needed?
Have the user supply a vector to populate. That way it acts as a reminder that the user has to destroy it because they created it.

Is anything missing, anything else that is needed when working with vectors?
Your suite of functions seems fairly comprehensive at this stage.