Spec#, nullables and more
Lutger
lutger.blijdestijn at gmail.com
Sat Nov 6 05:18:34 PDT 2010
retard wrote:
> Sat, 06 Nov 2010 10:20:24 +0100, Simen kjaeraas wrote:
>
>> Walter Bright <newshound2 at digitalmars.com> wrote:
>>
>>> Consider non-nullable type T:
>>>
>>> T[] a = new T[4];
>>
>> As others have pointed out, this would be impossible for a proper
>> non-nullable type. The only ways to create an array of non-nullable
>> elements would be a literal, concatenation with non-nullable elements,
>> or casting an existing array of nullable elements.
>
> That's bs.. the functional way to doing this is to wrap all elements in a
> Maybe monad. It makes the "null check" explicit.
Isn't a list of Maybe T a functional way to express the nullable side
effect, rather than express non-nullable types? After all, it is typed as
Maybe T, not T. There is a code path for nil in the monadic case right, but
not for nullable types. Or do I completely miss the point?
More information about the Digitalmars-d
mailing list