Boost logo

Boost :

From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-03-26 16:09:35


> So the ball is back in your court: Why should LL include the advanced
> statement and exception support?

class err;
int div(int i, int j) { if d = 0 throw err(); return i/j; }

for_each(a.begin(), a.end(),
           try_catch(_1 = bind(div, 1, _1),
           catch_exception<err>( _1 = 0 )))

The example form the docs will do for the switch statement:

for_each(v.begin(), v.end(),
    switch_statement(_1,
      case_statement<0>(std::cout << constant("zero")),
      case_statement<1>(std::cout << constant("one")),
      default_statement(cout << constant("other: ") << _1)
    )
);

What is so much wrong with these? I can easily depict myself using
something like this to take care one, two potential exceptions, or to
handle a few cases with a switch, instead of writing separate functors.

And I see no fundamentally different
alternative possible (without a core language change), the syntax can be
different obviously.

> I truly hope you can convince me that it is a
> good idea, and that the needed language support to make it great is realistic
> to achieve.

I really do not understand the argument that
we should not include some feature,
because it is not possible to make it perfect.
My belief is, that if we have tools like this availble
and see that they are useful and also notice that they are not perfect,
that is something that will boost language changes.
 

Cheers, Jaakko


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