Daniël Mantione wrote:
[..]
Stack allocation is much faster than heap allocation, and automatic.
Take a look at the matrix unit; you can return an object from a
function without worrying about memory leaks, so they are very usefull
in function results and operator overloading.
Further, objects allow you control the binary layout (the binary
layout is just like a record), which means you can fit existing data
structures (like those used in files) with methods. Some time ago we
had a discussion about this list about mapping the GTK Gobject model
to Pascal objects, succesfull experiments were done.
In a external c library, i have a structure like
TMyType = record
x: Integer;
y: Integer;
end;
PMyType = ^TMyType;
and a function that expects a pointer to that record
function DoIt(MyVar: PMyType);
can i safely use the below object instead of the record and pass
directly to the c function?
TMyObj = object
x: Integer;
y: Integer;
Method1;
Method2;
end;
PMyObj = ^TMyObj;
Moreover, whats the difference between objects and records with methods
(the new Delphi feature)?
Luiz
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal