[fpc-pascal] Stack alias for ARC like memory management?

Ryan Joseph ryan at thealchemistguild.com
Wed Apr 25 14:39:46 CEST 2018



> On Apr 25, 2018, at 7:14 PM, Marco van de Voort <marcov at stack.nl> wrote:
> 
> Ah, no the original code had two mistakes, the new code only one (the double
> free).
> 
> It does illustrate that the finalization of every object would have to be in
> its own try finally block though.

Sorry guys that was technically a bad example but it does illustrate the usage pattern and I think we can all identity it as being very common. It’s a smart optimization because we know with 100% certainty that those classes are only meant to be around for the duration of that functions body so we can optimize away the unneeded call to GetMem and calling Free when the function terminates. It’s like using “constref” for functions when you want to avoid a needles copy-on-pass, especially when the size is large. It’s just wasteful and could be avoided with a simple keyword.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list