Lifetime

The lifetime of a declared element is the period of time during which it is available to use. Variables are the only elements that have lifetime. But you can think of procedure parameters and function returns as special variables.

The lifetime of a variable is the period of time during which it can hold a value. Its value can change during its lifetime, but it always holds some value.

Different lifetimes

A member variable (declared at module level, but not in a procedure) usually has the same lifetime as the element in which it is declared. A non-shared variable declared in a class or structure is an isolated copy for each instance of the class or structure. Each such variable has the same lifetime as its instance. But a variable with @Shared has only one lifetime, which continues for the full run-time of a program.

A local variable (declared in a procedure) has lifetime only during the run-time of the procedure. The same applies to that procedure's parameters and function return, if applicable. But if that procedure calls other procedures, the local variables keep their values while the called procedures run.

Start of lifetime

TODO

End of lifetime

TODO

Extension of lifetime

TODO

Shared variables with the same name

TODO

Containers for Shared variables

TODO

Examples

TODO