The Nullable
type is needed to fix Tony Hoare's "billion dollar mistake".
But implementing the idea is full of pitfalls, e.g., Null
by itself should not be an expression.
▮
is the terminator to mark the end of a top level construct.
An Expression◅aType▻
is an expression which when executed returns aType.
In an expression,
1. ⦾
followed by an expression for a nullable returns the Actor in the nullable or
throws an exception iff it is null.
2. Nullable
followed by an expression for an Actors returns a nullable with the Actor.
3. Null
followed by aType returns a Nullable◅aType▻.
4. ⦾?
followed by an expression for a nullable returns True
iff it is not null.
Illustrations:
* 3▮
is equivalent to ⦾Nullable 3▮
* ⦾Null Integer▮
throws an exception
* True▮
is equivalent to ⦾?Nullable 3▮
* False▮
is equivalent to ⦾?Null Integer▮
In a pattern:
1. ⦾
followed by a pattern matches a Nullable◅aType▻ iff
it is non-null and the Actor it contains matches the pattern.
2. ⦾Null
matches a Nullable◅aType▻
iff it is null
Illustrations:
* The pattern ⦾x
matches Nullable 3
, binding x to 3
* The pattern ⦾Null
matches NullInteger
Edited for clarity
Recent comments
23 weeks 1 day ago
23 weeks 2 days ago
23 weeks 2 days ago
45 weeks 3 days ago
49 weeks 5 days ago
51 weeks 2 days ago
51 weeks 2 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago