Do statement memory question

Hey,
The documentation says do has no runtime cost and just creates a new scope.
Does that also mean if I declare a variable it will not be deallocated even after leaving the do block?

The variable is deallocated sometime after the last use. If compiler is doing a good job it might be much earlier than the end of the do block!

1 Like

Thanks :slight_smile:

1 Like

IIRC the variable is guaranteed to be deallocated sometime between its last use and the end of scope. Changing this so that it's always deallocated at the end of scope has been discussed, though.

1 Like