[fpc-pascal] Out of scope method?
Marco van de Voort
marcov at stack.nl
Thu Apr 6 13:10:31 CEST 2017
In our previous episode, Ryan Joseph said:
> > And reference counting as garbage collection method has been discussed to
> > dead on various maillists and forums. Both Delphi and Lazarus/FPC.
> Hmm, that sounds like a hack. Is the verdict this is generally a bad idea?
There is a reason why C++ only applies the basic RAII to stack objects: they
can't form cycles, and the time required is fairly predictable.
As soon as you allow references and thus complete, complex structures on the
heap this changes.
There are ways around this (by marking some references as weak as in ARC),
but in general it is not simple. Delphi's mobile compilers use this.
>I was just curious about it and it seems like a reasonable feature a
> language may have.
Search the web for more info. There is enough info on automatic memory out
there to satisfy any curiousity for years :_)
More information about the fpc-pascal