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

Bernd prof7bit at googlemail.com
Thu Jul 28 13:03:56 CEST 2011

2011/7/28 Bernd <prof7bit at googlemail.com>:
> And also maybe does some
> clever and elegant pattern exist that would enable me to simply reuse
> the instance of A (if an initialized object exists already on the left
> side of the assignment)

For example (pseudocode, not sure if this is allowed):

operator + (a,b: IBigNum):IBigNum;
  if not assigned(Result) then
    Result := TBigNum.Create;
  BN_add(Result.BN, a.BN, b.BN);

Am I allowed to access the Result in this way? I have done only a few
experiments and at one time it seemed I could indeed access values of
the fields of the object on the left side of the assignment through
the Result variable but I'm not sure whether this was only coincidence
or if this is actually allowed.


More information about the fpc-pascal mailing list