[fpc-pascal] operator overloading and counting references / creating / destoying anonymous instances

Bernd prof7bit at googlemail.com
Mon Aug 1 00:21:37 CEST 2011


2011/7/31 Honza <befelemepeseveze at gmail.com>:
> 2011/7/28 Bernd <prof7bit at googlemail.com>:
>> ยน I depend on OpenSSL already anyways, so I thought why not make use
>> of its bignum too when I need it.
>
> I hope you're aware of the FPC GMP bindings:
>
> http://wiki.freepascal.org/gmp

It seems the author fought with the same kind of problems and now
there exist two ways of using these bindings, a thin one and a fat one
with reference counting. I have considered this too.

But at the moment for my project the pragmatism has won: I need them
only for very simple operations in only a few parts of the application
and in tight loops where speed matters more than elegance or being
able to write A:=B instead of A.Assign(B).

This means I am now representing them as Objects (not classes) and
only a handful of inlined methods calling the external API and doing
nothing else, no reference counting, no additional overhead, its just
not worth all the effort for these 10 simple function calls (I'm not
even using the complete API, only the bare minimum).

Unfortunately Using the GMP library for *this* project is not an
option, it took me already a week to convince myself (and stop
evaluating alternatives) that there is no way around depending on
OpenSSL anyways (because I need ECDSA) and since this will also give
me some other things for free (SHA and RIPEMD which I also need) and
also the bignum that I need for Base58 I don't have to add yet another
dependency for any of these things (at the moment).

*Maybe* I will later (when it all works) find the time and replace it
with an existing native Pascal bignum implementation (I found one
already) and then try to use this to implement ECDSA in Pascal myself
and then get rid of OpenSSL altogether. But this has *very* low
priority and can be done at any later time.

Bernd



More information about the fpc-pascal mailing list