Boost logo

Boost :

Subject: Re: [boost] Interest in breakable labeled scope emulation?
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2013-01-16 12:33:52


On Tue, Jan 15, 2013 at 6:10 PM, TONGARI <tongari95_at_[hidden]> wrote:

> 2013/1/16 Jeffrey Lee Hellrung, Jr. <jeffrey.hellrung_at_[hidden]>
>
> >
> > It's a nice thought but:
> > (a) I think the situation where you want to break and/or continue more
> than
> > one loop-level out at a time is rare; and
> > (b) in those rare situations, explicitly using gotos and labels (with a
> > descriptive name) is reasonably brief and readable;
> > so I would be hesitant to adopt this.
> >
>
> Why not provide a more structured way for jumping if we really want to
> deprecate 'goto' in C++?
> It's not only for the old hands but the newcomers to adopt a more
> expressive control style.
>
> I think Boost is a good place to start with, and we'll see if it'd be
> finally made into C++ language.
>

I would be supportive in considering adding syntactic support for "break
LABEL" and "continue LABEL", but we have already have a reasonably good
emulation that's entirely transparent (meaning, not hidden behind macros):

{for(...) {
  for(...) {
    if(...)
      goto BREAK_FOR;
  }
}BREAK_FOR:;}

for(...) {{
  for(...) {
    if(...)
      goto CONTINUE_FOR;
  }
}CONTINUE_FOR:;}

- Jeff


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