Assignments of aggregate types (such as records, tables, or vectors) are always shallow, that is, they are performed by reference. So when you assign a record or table value to another variable, any modifications you make to members become visible in both variables (see also Record Assignment, Table Assignment).
The same holds for function calls: an aggregate value passed into a function is passed by reference, thus any modifications made to the value inside the function remain effective after the function returns.
It is important to be aware of the fact that events triggered using the
event
statement remain on the event queue until they are processed,
and that any aggregate values passed as arguments to event
can be modified
at any time before the event handlers are executed. If this is not desirable,
you have to copy the values before passing them to event
. The model that applies
here is one of reference counting, not local scope or deep copying.
If deep copies are desirable, use the clone operator “copy()” explained in
Expressions.
Therefore, if an event handler triggering a new event modifies the arguments
after the event
statement, these changes will be visible inside the event
handlers running later. This also affects the lifetime of a value. If an aggregate
is for example stored in a table and referenced nowhere else, then retrieved and
passed to an event
statement, and removed from the table before the
event handlers execute, it does remain in existence until the event handlers
are executed.
Furthermore, if multiple event handlers exist for a single event type, any changes to the arguments made by an event handler will be visible in other event handlers still to follow.