[Lazarus] "global" operator overloading

Michael Schnell mschnell at lumino.de
Wed Feb 27 10:48:05 CET 2013


On 02/26/2013 03:07 PM, Sven Barth wrote:
>
> The critical difference between records and classes besides the 
> ability of records to reside on the stack is that they don't allow 
> inheritance and they support variable parts. The "don't allow 
> inheritance" is important, because otherwise you'll have a certain 
> overhead like virtual method resolution.
I see. But this does not force that a synonyme for record could be a 
certain type of class, so that "class" in a straight forward and thus 
more "future-compatible" way can be used for any combination of fields 
of multiple types. (of course keeping the "record" syntax for compatibility)

>
>> AFAIK even old style Turbo-Pascal "Objects" are still in place.... That
>> could be a certain type of class as well.
>
> Yes, objects still exist as well and I still don't really understand 
> why Borland didn't revive them instead of adding methods to records...
I suppose they already marked "Object" as obsolete and did not want to 
admit the bad decision.  (Of course more sensible would have been to 
extend the count of "class" specifier keywords.)
>
> Nevertheless objects are between records and classes: they can also be 
> located on the stack (and be initialized as a constant) like records, 
> yet they support (if you need it) inheritance and virtual methods. 
> They can't implement interfaces though and there is no base object 
> type (similar to TObject). Also they don't support RTTI (though I 
> might change this with the extended RTTI).
> All three types, records, objects and classes have their purposes and 
> uses and one can select the one that is most fitting in a given 
> situation.
Yep. All in fact are sensible but the multiple syntax is rather queer 
(disregarding the history that led to it).

-Michael




More information about the Lazarus mailing list