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
20 weeks 1 day ago
20 weeks 1 day ago
20 weeks 1 day ago
42 weeks 2 days ago
46 weeks 4 days ago
48 weeks 1 day ago
48 weeks 1 day ago
50 weeks 6 days ago
1 year 3 weeks ago
1 year 3 weeks ago