Escape

A term for a way to exit the current or normal context. When quoting text, special character sequences may be used to make the difference between what is part of the text being quoted, and what part of the text quoting it.

Terminals use escape sequences to indicate things other than usual text, such as moving the cursor, changing the color of the text, etc.

A reference to an object is said to escape a scope if some objects outside of this scope may access it (for instance, because this reference was passed to an external procedure that may have had the side-effect of storing it).

An object is said to escape a scope when at least one reference to this object escapes the scope.

Many program transformations including garbage collection and various optimizations, depend on the ability to prove that some objects do not escape.

For instance, an efficient implementation for non-escaping objects would be to allocate them in a stack, and pop them out of existence when the function exits. Escaping objects, on the other hand, would require more expensive heap-allocation, with sophisticated garbage collection techniques.