On Monday, 11 October 2021 at 15:24:07 UTC, Adam D Ruppe wrote:
On Monday, 11 October 2021 at 15:18:11 UTC, Ferhat Kurtulmuş wrote:
"Each call to initialize must be paired by a call to terminate.'

It is so the refcount works out.

When you call initialize, it does something like:

if(refcount == 0)
   actually intialize; // calls constructors etc
refcount++;


When you call terminate, it does:

refcount--;
if(refcount == 0)
   actually terminate; // calls destructors etc



If you don't pair it, the refcount will be off, so the next call to terminate will still see ref > 0 and not actually terminate.

The D main inserts a call to init before main and a call to terminate after main automatically.

That makes sense, now I see, thank you again Adam.

Reply via email to