> On Apr 25, 2018, at 7:14 PM, Marco van de Voort <mar...@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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to