|
|||||
Functions: passing a shelf as a read-only argument | |||||
Prerequisite Concepts | Related Syntax |
A read-only argument is a reference to an existing shelf. A read-only argument is used to pass a shelf as a whole. It allows a caller to share a shelf with a function being called.
Unlike a value argument, a read-only argument cannot be used to pass the value of an expression.
A read-only argument is used to make the shelf accessible to the function, so that the function can read values and keys from it, but it can't be modified in any way. Read-only is essentially a promise by the function that it won't change the shelf in any way. That promise is enforced by OmniMark.
OmniMark does not permit any action on a read-only argument that would modify the shelf. It also does not permit a read-only argument to be passed to another function as a modifiable argument. These checks are done at compile-time and do not affect the run-time performance of OmniMark.
Certain predefined shelves are considered to be "read-only" and may only be passed as read-only arguments. They include #appinfo
, #doctype
, #item
, #first
, and #last
. (The values of individual items may be passed as value arguments as well, but that is not equivalent to passing the entire shelf.)
The value of an item on a read-only argument shelf may be passed to another function as a value argument or as part of a remainder argument. A read-only shelf may be passed to another function as a read-only shelf.
Prerequisite Concepts Functions Functions: argument classes Functions: argument shelf types |
Related Syntax define function |
---- |