> On May 6, 2021, at 10:44 AM, Marco van de Voort via fpc-devel 
> <fpc-devel@lists.freepascal.org> wrote:
> But those types have refcounting built-in and always active. Things like 
> defer don't, which makes that all objects gets refcounting overhead in case 
> somebody needs it for "defer".
> Contrary to Pascal both the language you reference have garbage collectors, 
> so their objects are already managed anyway,

The idea of defer isn't necessarily about memory management but rather 
literally just deferring a statements execution until a predicable point in 
execution (end of a block or function). Those articles mentioned using them for 
file IO also so that you can be sure you're going to close the open file handle 
even if the function returns before. Memory management is just one obvious use 
case since we have this problem in Pascal often.

I don't think this even affects ref counting of existing types because it all 
it does it move the statement to the end of the block. Maybe I'm not 
understanding your point though.

        Ryan Joseph

fpc-devel maillist  -  fpc-devel@lists.freepascal.org

Reply via email to