Current sentiment on Nullable.get
Atila Neves
atila.neves at gmail.com
Thu Dec 13 13:36:11 UTC 2018
On Tuesday, 11 December 2018 at 22:32:45 UTC, Jonathan M Davis
wrote:
> On Tuesday, December 11, 2018 2:48:36 PM MST aliak via
> Digitalmars-d wrote:
>> [...]
>
> Ultimately, allocation is the main difference here. Nullable
> provides a way to emulate the behavior of a pointer with
> regards to nullability without having to allocate on the heap.
> An Optional or Maybe type is ultimately the same thing, just
> with a different name. If it weren't for the issue of heap
> allocation, it could easily argued that pointers negate the
> need for any kind of Nullable/Optional/Maybe type, because they
> provide that functionality. And they don't even cause memory
> safety issues if you're not doing pointer arithmetic.
There's another fundamental difference with regards to pointers:
there's no equivalent to `null`, which is this weird special
value that is compatible with all pointer types.
More information about the Digitalmars-d
mailing list