I believe that the delayed object destruct is still in place though (see schedule_really_free_object in object.c). Test case:
int i;
class A { void _destruct() { i++; } }
int main(int argc, array argv) { if (1) { A a = A(); } werror ("i: %d\n", i); werror ("i: %d\n", i); }
Output: 8.1 marty$ bin/pike ~/free_object.pike i: 0 i: 1
“destruct_objects_to_destruct_cb”, which actually calls the code to process the list of objects scheduled for destruct, is installed as an evaulator callback. Evaluator callbacks are typically called on function calls, every now and then in backward jumps (i.e. loops) etc.
/Marty
On 29 Nov 2017, at 02:33 , Stephen R. van den Berg srb@cuci.nl wrote:
Martin Nilsson (Coppermist) @ Pike (-) developers forum wrote:
Why do we delay object destruction btw?
It appears that that is not the case anymore.
If I recall correctly, mast once explained to me that destructors of objects on the stack are called some time after a function has ended. I think I actually checked that, and that must have been in Pike 7.8.
The testprogram I just listed in the previous mail, seems to indicate that all objects are now destructed as soon as the scope closes. I.e. the delayed destruct is not happening any longer, regardless of the IMMEDIATE_DESTRUCT flag. It seems to work reliably for any nested block; which is great, because it makes it very intuitive to guess when destructors are being executed. -- Stephen.