Subject: Re: [boost] [metagraph]
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2012-02-03 01:33:20


Hi Abel,

On Feb 2, 2012, at 4:09 PM, Abel Sinkovics wrote:
> The do and let notations are general tools for monads - if you need exception propagation only, there is another utility for that in metamonad: the try_ template (http://abel.web.elte.hu/mpllibs/metamonad/try_.html). Instead of writing
>
> template <class T1, ..., class Tn>
> struct my_metafunction : body {};
>
> you write
>
> template <class T1, ..., class Tn>
> struct my_metafunction : try_<body> {};
> and it instruments body to propagate errors.

If body calls another metafunction then does that one have to be instrumented too?

> To support the use case when people don't want to pay for exception propagation, I can extend metamonad the following way: when a macro (eg. DISABLE_TMP_EXCEPTIONS) is defined, try_ becomes the identity metafunction. In that case it will have a minimal cost (1 extra instantiation). What do you think?

That sounds like a good idea but I haven't experimented with the library yet. Your library came up because a recursive depth-first-search isn't interruptible without exceptions, but I'm still not sure whether that means getting rid of recursion or introducing exceptions.

Cheers,
Gordon