[Lazarus] "global" operator overloading
xrfang at gmail.com
Tue Feb 26 09:36:22 CET 2013
Could you please give a simple example that shows what you said: require
that the type with which you specialize is a record. Then a class operator
in that record can be defined.
2013/2/26 Sven Barth <pascaldragon at googlemail.com>
> 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.
> >> is because the symbol table when the generics is parsed must be
> >> reconstructed when it gets specialized. Think about declaring usual
> >> with the generic parameter replaced with actual type. If at that time,
> >> 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)
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus