Boost logo

Boost :

Subject: Re: [boost] [Boost.Breakable] Any interest in a Boost Breakablelibrary?
From: David Bergman (David.Bergman_at_[hidden])
Date: 2009-09-06 15:56:58


On Sep 6, 2009, at 3:48 PM, vicente.botet wrote:

> Hi,
> ----- Original Message -----
> From: "Pierre Morcello" <pmorcell-cppfrance_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Sunday, September 06, 2009 7:58 PM
> Subject: Re: [boost] [Boost.Breakable] Any interest in a Boost
> Breakablelibrary?
>
>
>
> Hi, there is no difference.
>
> Indeed, the macro as I use it right now is even less optimised than
> a GOTO or a do...while(false) : it's currently just a simple 'for'
> loop in a macro..
>
> The aim is to make code more readable. A goto is a pain to manage
> when you use a lot this 'breakable' structure.

If you use a lot of that 'breakable' structure - or its concrete
counterparts (single-iterative for-loops or do-while's) - you might
consider an overhaul of your code. I have written a lot of abstract
machines and compilers so I am aware of the (quite few) cases where
goto's and such use of breaks are justified, but such cases are rare.
My remark is not meant to be snide, just an advice from an old fart,
having wrestled, and eventually mastered, C++ for the last 20 years :-)

> The fact that it is easy to use and readable makes it easier to use
> a lot. In the end, I happen myself to use it lot more than I thougth
> I would at first. That is the main reason why I am proposing it here.
>
>>>> Both are probably shorter to write.
> Yes, although someone using such library may redefine the macro as
> he wishes :
> e.g. #define Breakable BOOST_BREAKABLE
> I am just conforming to BOOST coding style.

A comment regarding interest: no, I am not interested. As sebastian
pointed out, "do { .... } while (false);" is simple enough, and ugly
enough to at least make the coder think twice before using it :-)

/David


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