[Lazarus] Easiest way to "case" strings

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Mar 26 09:29:39 CET 2009


Flávio Etrusco schrieb:

>>> What is the function of being able to add methods to records?
>> Not much, I agree, given the existence of objects. It would be better to do that
>> instead of introducing 'object' keyword, but that decision was made
>> back in the days
>> of Borland Pascal.
> 
> Indeed, not much, but the memory savings can be really interesting in
> some situations.

The storage of class instances can be modified by overriding the 
according methods. I did so for arrays of instances, and it worked fine 
in Delphi. With some tricks it should be possible to have both static 
and dynamic allocation, for the same class type.

I also found at least one use for records with methods, in the emulation 
of C structs with bitfields or unions. For that matter 'object' and 
properties came in handy.

IMO one difference between class and record will stay that records 
cannot have virtual methods (in Delphi), due to the inlined VMT 
pointers. Another difference will be heritage - records are not extensible.

BTW, 'object' became deprecated (in Delphi) only when the 
reference-counted data types have been introduced. Delphi (willingly) 
doesn't support properly objects inheriting from another object type, in 
which case only the top level type is initialized and finalized 
properly. I wonder why the same construct with records (nested in 
records) has been made work, then.

DoDi




More information about the Lazarus mailing list