Low-Lock Singletons In D

bearophile bearophileHUGS at lycos.com
Fri May 24 07:29:37 PDT 2013


Max Samukha:

> It could be normalized by free functions isNull(T)(T t), 
> nullableValue(T)(..) etc.

In Haskell/Scala if you program idiomatically you usually use 
HOFs as map, filter, etc that work "transparently" on nullables 
or collection of nullables, because Maybe is a monad.
Example: you have a range of nullables, and you map a function on 
it, using a special map that ignores the null items. (This is one 
of the improvements I have suggested in Bugzilla.)


>> But often you want to use something like Nullable(int*, null) 
>> or Nullable(int*, cast(int*)null) instead.
>
> Do you have an example? In what cases is the distinction 
> between a null null int* and non-null null int* necessary?

If you use a Nullable!(int*, null) type that distinction 
vanishes, there is only one null.

Bye,
bearophile


More information about the Digitalmars-d mailing list