Re: While loop style

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



OK, thanks Rodrigo,

The person had included the semi-colons. The code compiled, but was not
tested.
I found the code and had to ask what it was actually supposed to do.

Using the braces would have made it clear what the intention was and more
importantly would have made the error much less likely to happen, since the
brackes are what's important, not the indentations.



"Joe Butler" <ffffh.no.spam@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:OwRQa3dkFHA.4000@xxxxxxxxxxxxxxxxxxxxxxx
> Yes, go with that.
>
> Its meaning is absolutely clear - even if someone does some sloppy editing
> around it at a later time.
>
> Why have while loops with blocks and another while loop withouts blocks
just
> for the sake of typing a couple of braces?
>
> I've actually seen people write code like this:
>
> while(whatever)
> DoStuffFunction()
> DoSomeOtherSubtleStuffThatHasBeenAddedLaterFunction()
>
> Now, what do you suppose would have happened if there were braces around
> that while in the first place?
>
>
> "Charles Tam" <CharlesTam@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:DAF56A25-FB5B-4F8E-A347-D0BD2F60FCD2@xxxxxxxxxxxxxxxx
> > I've a while loop as below, and would like to execute the true
expression
> > until false. Is my style of ";" correct?
> >
> > FYI: queue.remove() returns true if element is removed, false if queue
is
> > empty. Note, the queue do not provide a isEmpty funtion.
> >
> > ////////////
> > while ( queue.remove() )
> > {
> > ;
> > }
> > ////////////
> >
>
>


.



Relevant Pages

  • Re: While loop style
    ... Why have while loops with blocks and another while loop withouts blocks just ... what do you suppose would have happened if there were braces around ... > I've a while loop as below, and would like to execute the true expression ... the queue do not provide a isEmpty funtion. ...
    (microsoft.public.vc.language)
  • Re: Delaying events for fixed amounts of time.
    ... amount of time after the *FIRST* event with a given key arrives. ... I have anything Windows has to offer. ... Pause for, say, 250ms each time through the loop ... Have a queue of keys, each time a new key arrives, add it to the end ...
    (comp.programming.threads)
  • Re: Threading help... threads???
    ... it appears as if you have an endless loop. ... remove the call record from the queue and make the call. ... End Sub ... 'derived classes must override. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Delaying events for fixed amounts of time.
    ... amount of time after the *FIRST* event with a given key arrives. ... Process events as timers expire. ... Pause for, say, 250ms each time through the loop ... Have a queue of keys, each time a new key arrives, add it to the end ...
    (comp.programming.threads)
  • Re: Threading help... threads???
    ... that it sat in a loop doing the following ... > queue" to see if there were any calls to be made. ... > Protected Overrides Sub Execute() ...
    (microsoft.public.dotnet.languages.vb)