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

Bernd prof7bit at googlemail.com
Fri Jul 29 12:00:12 CEST 2011


I have run across another even more severe problem: Although using
reference counted interfaces makes everything work without memory
leaks there is one problem that gives all the nice syntactic sugar a
really bad taste:

A := B

I am not allowed to overload the assignment of equal types. This means
in the above I would have created a reference to B instead of a copy.
If I now do an operation on A that does *not* create a new instance of
it I will also change the value that B is pointing to, so I am
*forced* to make new instances even if I could in some cases easily
avoid them. Otherwise the user of that unit would have many
WTF-moments when debugging the unexpected strange behavior in his code
and all the efforts of making it look and behave natural would
effectively be nullified by such a problem.

Bernd



More information about the fpc-pascal mailing list