I'm not entirely sure this would work. This e.g. because you don't know if a result an operator gives back is a temporary result (needing to be GCed) or a final result that might be stored somewhere permanently.
To this problem there are two "normal" and two halve "weird" solutions:
the whole solutions:
- use a record with a dynamic arrays of a static or ref counted type. Since dyn arrays are automatically disposed, so will be the result
- use a class instead of a record, but make the reference an interface. Interfaces are refcounted, and can clean up after themselves
The halve solutions mess with memory allocation as a whole; I've heard both only described, not tested them myself:
The first workaround I've oassumes you need the GCed type only for intermediate results, and use a conversion (e.g to double or so) for the final result.
This means that if you hand out allocations from a block, and after a while move on to the second block, you can, after another while, simply deallocate the first block as a whole (including child fields). If the beast is a class, have a look at newinstance. Overriding it might help you there.
The last one is the big one. Try to use a existing Boehm GC as can be used with C and C++. This is a very complex issue, untested, and not much is known about it. The following page in the wiki summons up the bits that are known (i.c.w. FPC)
http://wiki.freepascal.org/garbage_collection