[Lazarus] "global" operator overloading

Sven Barth pascaldragon at googlemail.com
Tue Feb 26 09:07:14 CET 2013


Am 26.02.2013 08:59 schrieb "xrfang" <xrfang at gmail.com>:
>>
>> No, it's not a dilemma, but rather a requirement. Before generics
>> specialization, all required operations for given type must be known.
This
>> is because the symbol table when the generics is parsed must be
>> reconstructed when it gets specialized. Think about declaring usual
classes
>> with the generic parameter replaced with actual type. If at that time,
the
>> operation < is not yet defined, the code won't compile anyway.
>
>
> It is a pity. I think if fpc supports class operators, maybe this problem
could be solved by using class helpers (my purpose is that users of ttreap
class does not have to modify treap.pas) ? Is that possible in future FPC?

Helpers have the same problem. For now there is only one solution (as I
already wrote): require that the type with which you specialize is a
record. Then a class operator in that record can be defined.

For the future I already have the following longterm plans:
- add class operator support to class and object
- allow to specify additional units after "specialize" that will be used
when specializing (they will be added first, so that the original code is
not unnecessarily modified)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130226/66a956c3/attachment-0003.html>


More information about the Lazarus mailing list