[Lazarus] "global" operator overloading

Xiangrong Fang xrfang at gmail.com
Tue Feb 26 09:36:22 CET 2013


Hi Sven,

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.

Thanks

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.
> 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
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130226/990a9e9d/attachment-0003.html>


More information about the Lazarus mailing list