Benchmark of try/catch
Rainer Deyke
rainerd at eldwood.com
Tue Mar 24 18:49:09 PDT 2009
Daniel Keep wrote:
>> int? value1 = atoi("0"); // 0
>> int? value2 = atoi("#!$"); // null
>
> Not quite; that assumes null isn't a valid value. What if the function
> was "getInstance"?
T?? value = getInstance();
> Here's how I understand it to work. Functions may return a Maybe!(T),
> which is either a T or None (note that None is not null), and is
> implicitly castable to T.
'T??' (aka 'Maybe!(Maybe!(T))') must be a valid type.
In Haskell, a 'Maybe Maybe Integer' can be 'Nothing', 'Just Nothing', or
'Just Just 5'.
In C++, given 'boost::optional<boost::optional<int> > o', you can have
'!o', '!*o', or '**o == 5'.
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list