Boost logo

Boost :

Subject: Re: [boost] [next gen futures] Lightweight monad ready for inspection
From: Bjorn Reese (breese_at_[hidden])
Date: 2015-06-20 07:48:29


On 06/19/2015 07:03 PM, Niall Douglas wrote:

> https://github.com/ned14/boost.spinlock/blob/master/include/boost/spinlock/monad.hpp

This starts with the words "The world's most simple C++ monad" followed
by 1200 lines of code... makes one scared of monads.

Here are some random throughts I had while reading the code.

Minor comment, consider letting monad_error inherit from system_error
instead of logic_error.

When throwing monad_error, you cast to int (presumably to satisfy some
compiler.) Can't you simply use make_error_code() instead? That will
also ensure that you set the correct category.

Why does one of the value_storage constructors call abort() rather than
throwing an exception?

Why does monad::get_error() throw on no_state, rather than simply
returning an error_code that says so?

Is there any difference between monad::get() and monad::value()? If
they are synonyms, then you may consider removing monad::get() to keep
the class interface smaller, and instead overload std/boost::get().


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk