07.3 Option and nullability
Option T is the only optional surface, no null, no optional keyword.
Option and nullability
If you type null expecting sympathy, you will receive diagnostics instead.
Option<T> only
Section titled “Option<T> only”Optional presence must use Option<T> (corelib Core.Optional.Option) or an explicit enum with a dedicated absent variant at API boundaries.
- Forbidden:
null,optionalkeyword,?Tsugar - Present / absent:
Option<T>::Some(x)/Option<T>::None(exact constructors per corelib)
Why the industry default is rejected
Section titled “Why the industry default is rejected”null made billion-dollar bugs feel normal. Beskid chooses explicit enums so absence shows up in match, not in a surprise NRE at runtime.
Handling options
Section titled “Handling options”Use match on options (see enums and match). Calling methods on a maybe-absent value without narrowing is a compile error, not a Friday production mystery.
classDiagram
accTitle: Option as an enumeration
accDescr: Option of T is an enumeration with the variants Some and None, and a match on it handles both.
class Option~T~ {
<<enumeration>>
Some(T)
None
}
class MatchExpression {
handles None as absent
handles Some as inner T
}
MatchExpression ..> Option : narrows
Text equivalent: Option<T> is an enumeration with variants Some(T) and None. A match narrows it, handling the absent case and using the inner T in the present case.
Normative decisions
Section titled “Normative decisions”- D-LM-TYP-002:
Option<T>only in Types - Glossary: glossary and conformance