## D - two cents

• hrdo (5/21) Aug 16 2001 Why not use the loop counter and just say:
• Walter (4/24) Aug 16 2001 Because the loop counter could be any expression, or even no expression ...
• Michael Gaskins (4/26) Aug 16 2001 The coder can still just use a 'break' with no label to break out of the
• Walter (2/4) Aug 17 2001 Yes.
• Sean L. Palmer (7/11) Nov 04 2001 You know, I've sometimes wished for the ability to break out of a if or ...
• Walter (6/20) Nov 19 2001 Having a goto can be pretty handy now and then.
"hrdo" <hrdo myrealbox.com> writes:
```   Break and continue statements can be followed
by label. The label is the label for an enclosing
loop or switch, and the break applies to that
loop.

Louter:
for (i = 0; i &lt; 10; i++)
{
for (j = 0; j &lt; 10; j++)
{
if (j == 3)
break Louter;
if (j == 4)
continue Louter;
}
}
// break Louter goes here

Why not use the loop counter and just say:
break i;
continue i;

Regards

john
```
Aug 16 2001
"Walter" <walter digitalmars.com> writes:
```"hrdo" <hrdo myrealbox.com> wrote in message
news:9lh86e\$2sne\$1 digitaldaemon.com...
Break and continue statements can be followed
by label. The label is the label for an enclosing
loop or switch, and the break applies to that
loop.

Louter:
for (i = 0; i &lt; 10; i++)
{
for (j = 0; j &lt; 10; j++)
{
if (j == 3)
break Louter;
if (j == 4)
continue Louter;
}
}
// break Louter goes here

Why not use the loop counter and just say:
break i;
continue i;

Because the loop counter could be any expression, or even no expression at
all. -Walter
```
Aug 16 2001
```The coder can still just use a 'break' with no label to break out of the
currently executing loop right?

"hrdo" <hrdo myrealbox.com> wrote in message
news:9lh86e\$2sne\$1 digitaldaemon.com...
Break and continue statements can be followed
by label. The label is the label for an enclosing
loop or switch, and the break applies to that
loop.

Louter:
for (i = 0; i &lt; 10; i++)
{
for (j = 0; j &lt; 10; j++)
{
if (j == 3)
break Louter;
if (j == 4)
continue Louter;
}
}
// break Louter goes here

Why not use the loop counter and just say:
break i;
continue i;

Regards

john

```
Aug 16 2001
"Walter" <walter digitalmars.com> writes:
```Michael Gaskins wrote in message <9li9d7\$o5u\$1 digitaldaemon.com>...
The coder can still just use a 'break' with no label to break out of the
currently executing loop right?

Yes.
```
Aug 17 2001
"Sean L. Palmer" <spalmer iname.com> writes:
```You know, I've sometimes wished for the ability to break out of a if or else
statement-- perhaps any block.  Unfortunately that would make conditionally
breaking out of a loop difficult.  It usually indicates a need for a goto,
which I am glad to have in the language BTW.

Sean

"Walter" <walter digitalmars.com> wrote in message
news:9liija\$11h1\$2 digitaldaemon.com...
Michael Gaskins wrote in message <9li9d7\$o5u\$1 digitaldaemon.com>...
The coder can still just use a 'break' with no label to break out of the
currently executing loop right?

Yes.

```
Nov 04 2001
"Walter" <walter digitalmars.com> writes:
```Having a goto can be pretty handy now and then.

"Sean L. Palmer" <spalmer iname.com> wrote in message
news:9s34o4\$2imj\$1 digitaldaemon.com...
You know, I've sometimes wished for the ability to break out of a if or

else
statement-- perhaps any block.  Unfortunately that would make

conditionally
breaking out of a loop difficult.  It usually indicates a need for a goto,
which I am glad to have in the language BTW.

Sean

"Walter" <walter digitalmars.com> wrote in message
news:9liija\$11h1\$2 digitaldaemon.com...
Michael Gaskins wrote in message <9li9d7\$o5u\$1 digitaldaemon.com>...
The coder can still just use a 'break' with no label to break out of

the
currently executing loop right?

Yes.

```
Nov 19 2001
"Robert W. Cunningham" <rwc_2001 yahoo.com> writes:
```Walter wrote:

Having a goto can be pretty handy now and then.

I've had to do some "portable" bare-metal C programming, which basically means
I got as close to assembler as I could using C, and then checked the assembler
output for a variety of targets.  Having a goto available saved my butt more
than once, especially when DSP, CISC, RISC (and once even an SIMD vector
supercomputer) compilers output very different code for specific conditional
tests and looping constructs.

Careful use of goto will even allow some fairly elegant OOPification of such
low-level code, making it all the more maintainable.  Just in case I ever need
to "escape" from D's object model, I'd like to have a goto available to help
craft a tiny workable substitute.

It was always a pain to create such code, but the result was extremely
efficient and portable, all without using assembler or platform-specific
defines.  Ya just gotta love C.  And the goto statement.

Of course, sometimes I naturally had to forbid compiler upgrades for all
targets...  At least for key modules.   ;^)

And what would such code be used for, you ask?  Well, the first time I crafted
such code was about 15 years ago, for a rather complex integrated audio and
video processing library.  Our favorite demo for the library would turn a Cray
into a real-time polyphonic guitar processor (complete with a full set of
simulated stomp boxes) and light show (driving multiple displays in sync with
whatever was being played on the guitar).  The real uses of the package were
classified, and I have no idea what they were (though real-time sonar analysis
and display does seem a distinct possibility).

The best part of building that demo was figuring out how to hook a Fender
Stratacaster up to a Cray...

-BobC
```
Nov 20 2001
"Walter" <walter digitalmars.com> writes:
```"Robert W. Cunningham" <rwc_2001 yahoo.com> wrote in message
news:3BFB22BD.BC665081 yahoo.com...
Careful use of goto will even allow some fairly elegant OOPification of

such
low-level code, making it all the more maintainable.  Just in case I ever

need
to "escape" from D's object model, I'd like to have a goto available to

help
craft a tiny workable substitute.

I've never liked the Pascal religion which required the creation of numerous
dummy flag variables whose only purpose was to emulate a goto.
```
Nov 21 2001
"Pavel Minayev" <evilone omen.ru> writes:
```"Walter" <walter digitalmars.com> wrote in message
news:9tfn7j\$1ql1\$2 digitaldaemon.com...

I've never liked the Pascal religion which required the creation of

numerous
dummy flag variables whose only purpose was to emulate a goto.

All implementations of Pascal I ever used (BP, Delphi, FreePascal, Virtual
Pascal) support goto.
```
Nov 21 2001