4 ms·
The difference is that the null check is front and center, instead of hidden. In C# or Java, the member access expression "a.b" contains a null check. There's
by Strilanc 13y ago
The difference is that the null check is front and center, instead of hidden.
In C# or Java, the member access expression "a.b" contains a null check. There's no way to do a member access that doesn't do a null check (for reference types)! It's impossible to distinguish member accesses that were expected/assumed by the writer to not fail from member accesses where the check is relied upon.
With an option type / a maybe monad / 'using telling instead of finding', there are no implicit null checks. Only explicit checks, and only when necessary. Either you use Option.map, to do a check and propagate nulls, or you don't, in which case there's no null path. You don't have to worry about null reference exceptions, making a check where you shouldn't, or missing a check where you should have, because the compiler prevents you from making those mistakes.
Applying it to C++: https://github.com/simonask/simonask.github.com/blob/master/maybe.markdown https://github.com/simonask/simonask.github.com/blob/master/...
Applying it to C# (as an augment over null): http://twistedoakstudios.com/blog/Post1130_when-null-is-not-enough-an-option-type-for-c http://twistedoakstudios.com/blog/Post1130_when-null-is-not-...
Applying it to Java (as an alternative to null): http://java.dzone.com/articles/java-optional-objects http://java.dzone.com/articles/java-optional-objects
- topbanana 13y agoOff-topic but I find the color scheme of your blog very offputting