Regarding Nullables
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 17 09:06:12 PDT 2014
On Sunday, 14 September 2014 at 20:10:27 UTC, Dmitry Olshansky
wrote:
> 13-Sep-2014 23:39, Andrei Alexandrescu пишет:
>> On 9/13/14, 8:36 AM, bearophile wrote:
>>> This is a little Haskell program that uses the Maybe type
>>> constructor:
>> [snip]
>>
>> As others noted, I think we need a kind of range with either
>> zero or one
>> element. Also, the range would have an "exception" property
>> that returns
>> null if the operation was successful (and the element is
>> there) or
>> whatever exception produced the result. E.g.:
>>
> I think it may be a bit too much to mix "exception or ok" and
> "1 or none" into a single type. Otherwise I agree.
>
> For precedents e.g. Scala has Option!T (or rather Option[T])
> and Try[T] to denote Some!T or None, and Success!T or
> Failure(Throwable) respectively. And then uses composition to
> cover all of potential combinations.
I agree with Dmitry - mixing too many independent concepts into
one entity will make it less widely usable and create false
expectations. Better to keep such things independent.
More information about the Digitalmars-d
mailing list