|
|||||
Referents: specifying default definitions | |||||
Prerequisite Concepts | Related Syntax |
A defaulting
part can be specified with referents-allowed
in an open
action. It has two possible forms. It can be specified with either one string expression or two, and provides an effective value for referents as follows:
If there is one string expression, then that is the effective value. For example, if a referent does not provide an effective value and the stream's associated referent set is declared as follows, then the referent's effective value is "no value".
open s with referents-allowed defaulting {"*no value*"} as file "s.txt"
To ensure that undefined referents are simply omitted from any stream to which they are written, use the zero-length string as their default effective value, as in:
open s with referents-allowed defaulting {" "} as file "s.txt"
If there are two string expressions, then the effective value is the name of the referent, with the first string preceding it and the second following it. For example, if a referent whose name is "my-ref" has no contents, but the stream to which it is written is opened as follows, then the referent's effective value is "(undefined referent="my-ref")":
open s with referents-allowed defaulting {"(undefined referent=%"", "%")"} as file "s.txt"
To get just the name with no surrounding text (preceding or following the referent name, or both), use two zero-length strings, as in:
open s1 with referents-allowed defaulting {"", ""} as file "s1.txt"
The defaulting
part, if any, used to provide the effective value of an undefined referent is the defaulting
part associated with the "final destination" of the referent. This has a number of consequences:
referents-allowed
buffer or referent is copied to another referents-allowed
stream, and any of the referents in the buffer or referent are undefined, it is the defaulting
part of the copied-to stream, not the copied-from buffer or referent, that is used.
referents-allowed
has referents written to it that contain more deeply nested referent sets, then, when the referent set of the referent being written to is exited, the referent is replaced in the stream by its current effective value in the context of the stream. If such a referent is undefined, the defaulting
part associated with the stream, if any, is used. When resolving referents on exit from a referent set (using nested-referents
), the stream to which referents (of the nested referent set) have been written at that point is considered their "final destination", regardless of where the stream may be copied to outside of that set.
referents-displayed
is specified never uses any defaulting
part to provide an effective value.
defaulting
part specified when opening a stream, which is attached to a referent that also has referents-allowed
, is only ever used to provide an effective value for undefined referents that are written to the stream from more deeply nested referent sets.
Prerequisite Concepts Referents |
Related Syntax defaulting |
---- |