2011/7/28 Bernd <prof7...@googlemail.com>: > I have tried making > use of Interface and TInterfacedObject and this seems to do what I > want: for example when witing A := A + B the + operator would return a > new instance and the reference counting would then automatically call > the destructor of A when it assigns the newly created number.
I have profiled it http://imagebin.org/165317 procedure Loop(a,b: IFoo); var I : Integer; begin for i := 0 to 10000 do begin //BN_mul(b.Handle, a.Handle, a.Handle, b.Context); b := a * a; end; end; This creates and destroys an object of TFoo everytime and this in turn will also create and free resources inside OpenSSL, its only spending 37% of the time doing actually useful work (BN_mul). I think I'm not going to continue this route. I can't see any possible way to make useful use of overloading these operators, other than making a few lines in other places of the code look a little bit nicer at the cost of degrading performance by a factor of 3 (for add instead of mul its even factor 6). Occasionally I hear other people mentioning operator overloading as a must-have feature of any decent language but I wonder what real-world problems they are actually solving with it. Are other compilers better at dealing with these problems, is there room for improvement? Bernd _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal