1

It turns out that all variables, parameters of function are not deleted after the end of function's work, because only objects are deleted.

But what about lexical environment then? This object is created when the function is called, it contains all local variables, parameters... And this object is deleted when the function ends its work.

Or... variables are not deleted? Only what was copied into the lexical environment is deleted? How should I understand this?

Do all local variables remain after the end of function's work? Or not? And what's happening with objects, which are inside function? When does garbage collector understand that it's time to delete these objects?

Ivan
  • 478
  • 2
  • 13
  • 1
    "*because only objects are deleted.*" - what do you mean precisely? And where did you get this from? It seems your whole question is based around a misconception. – Bergi Apr 16 '21 at 11:13
  • 1
    Isn’t this the same question as [your previous question](https://stackoverflow.com/q/67096500/2711488)? Then, [again](https://stackoverflow.com/questions/67096500/#comment118620573_67096500), in an implementation, some things might not be handled by the garbage collector, because they don’t need to be handled by the garbage collector. Like local variables whose life time has not been extended by a closure. They will be deleted, whatever that means for the particular implementation, when the function ends. And an object is just a set of variables; deleting an object means deleting all of them. – Holger Apr 16 '21 at 12:17

0 Answers0