[fpc-pascal]Class Identification?

Michael Van Canneyt michael.vancanneyt at wisa.be
Mon Mar 24 15:33:33 CET 2003

On Mon, 24 Mar 2003 memsom at interalpha.co.uk wrote:

> Write a procedure or function that takes a 'self' pointer to the data. This is
> basically what methods are at the end of the day.
> If you want better allocation performance, you can always refactor the memory
> allocation routines too. If FPC follows Delphi's model, there will be a record
> that holds the memort allocation routines. Have a look for the record type
> TMemoryManager that will probably be located in System or Sysinit unit.
> Altering the way these routines work can greatly improve speed and resource
> usage.
> One other point.... you really should use 'is' and not 'MyObject.ClassType'.
> Surely:
>  if ( myinst is TButton ) then begin
>    ...
>  end;
> looks less ugly than:
>   if ( myinst.ClassType = TButton ) then ... ;

This is not entirely correct.
The latter will return false for a descendent of TButton, while the
former will give true. The exact statement corresponding to the
'is' operator is

if myinst.Inheritsfrom(TButton) then ... ;

Just crossing the t's and dotting the i's...


More information about the fpc-pascal mailing list