From: Officer Barbrady
type color = record
test:string;
end;
function color.showColor:string;
begin
result := self.test;
end;
begin
end.
wee ok got it
That method makes things faster right?
Performance wise, there's no significant difference if you access the record field directly instead. Though if you create a getter and setter method for each field you could imitate object-oriented programming, though not quite the case since you can't declare the fields as private.
The main purpose of type methods is just to make methods more readily understood and the code more readable.
For instance, you will need to remember to use GetTPABounds() to get the bound of a TPA, and GetATPABounds() to get the bound of ATPA.
If the developer create type methods for both of them to return the bounds, you can simply do
TPA.getBounds(); //gets the bound of TPA
ATPA.getBounds(); //gets the bound of ATPA
So in essence, you just need to remember to call .getBounds to get the bound of whichever type :)
As all non-primitives are stored as references (pointers to the memory addresses) in lape, this feature is extremely useful as we can just make .equals methods for all the types (rather than a standard-alone function for every type, which is much harder to use and uglier as well)