If you have

type 'a option = None | Some 'a

you have a so-called "lift" where "None"  is a new value playing the role
as no-information or "null". This allows you use the full range of 'a
whatever that is, because you glued a new null-value to it.

However, the problem you may face is that a lot of programming *do* need a
null value. So you end up having to handle these values quite a lot in your
program. Of course, as you grow better at detecting this, you seek to
untangle an option type early on in your program flow such that you avoid
those pesky null checks, and case/switch/match splits in the program. But
there are data out there for which this is hard to do correctly. Also for
the fact that the rest of the world is littered with data representations
in which null occurs all over the place.

The option type is theoretically stronger because the programmer can choose
when they need a nullable value and when they don't. It is usually easier
to add something (i.e., a null) than it is to remove it. This means it
carries more information to be exploited by the compiler and users of the
type. In practice, the world has miserable handling of data, and we spend a
considerable amount of time trying to get it pristine for use in our
programs. Thus, the value diminishes somewhat. However, if you manage to
carve out a small bubble in which you have absolute control over the data,
you are definitely in for a treat.


On Tue, Feb 18, 2020 at 12:58 PM Volker Dobler <[email protected]>
wrote:

> On Tuesday, 18 February 2020 12:44:16 UTC+1, [email protected] wrote:
>>
>> Well, other languages use the optional/maybe type. It handles sentinel
>> values pretty well and I don't think they bring new kind of bugs (while
>> they remove the nil-pointer related bugs).
>>
>
> That is the market claim. And typically for such claims it does not hold
> up.
>
> V.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/7199346c-36c8-46ba-97d3-d3ceec6632c1%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/7199346c-36c8-46ba-97d3-d3ceec6632c1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
J.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGrdgiVJk0%3D_PnWHAny0TPLgbT%3D52_Td_wZiJRoQm3KmfLEgCA%40mail.gmail.com.

Reply via email to