Lars Viklund | 11 May 04:24
Picon
Picon
Picon
Favicon

Re: Maybe a, The Rationale

On Sun, May 11, 2008 at 02:59:32AM +0100, Eric Stansifer wrote:
> I definitely agree.  After I'd been learning Haskell for 6 months and
> then wrote a program in Java & C++, almost the first thing I did was
> code up a generic Maybe<T> class in each language.  It is so much
> clearer and more obvious to _explicitly_ have no value
> (Maybe.Nothing()) as opposed to _implicitly_ having no value (null).
> Now I find my Java & C++ Maybe<T> class indispensable when I am
> programming in those languages.

You may want to take a peek at the Boost.Optional [1] library in C++, which
provides a lovely Maybe-like class template called "optional".

[1] http://www.boost.org/doc/libs/1_35_0/libs/optional/doc/html/index.html

--

-- 
Lars Viklund | zao <at> acc.umu.se | 070-310 47 07

Gmane