The SentinelPattern occurs when a unique value, outside the set of "domain" values, is used to communicate information to and/or from a function or subsystem.
Examples:
- The NullPointer is frequently used as a sentinel value in many instances, in particular when a non-NULL value is usually expected. (As NULL has other uses, this is sometimes controversial; see NullConsideredHarmful).
- Other scalar values are used for this purpose as well. EOF (-1) is used by the CeeLanguage standard library (as well as many OS-specific libraries) to indicate an I/O operation could not complete due to the end of file being reached; other errors and conditions are also handled in this manner.
- In SmalltalkLanguage, atomic strings (like #doesNotUnderstand) are used to signal all sorts of error conditions. Unlike the first two examples, the error codes in Smalltalk are seldom if ever part of the domain of the application data. See DeferredExceptionObject
See also
InBandSignal