Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Empty for loop

Name: Anonymous 2009-03-14 16:40

I just came across a for(;;) while reading through MSDN on winsock.

What is the purpose of an empty for(;;) loop? Can not the exact same thing be accomplished with a while loop? Seems like tomayto-tomahto to me. If there is some significant purpose though, I'd much like to know.

Name: Anonymous 2009-03-14 16:43

Why weren't you reading through SICP?

Name: Anonymous 2009-03-14 16:45

What is the purpose of an empty for(;;) loop? Can not the exact same thing be accomplished with a while loop?
I thought that the question was ``what's an empty loop good for?'', but you worry about how to technically do one? HIBT?

Name: Anonymous 2009-03-14 16:54

>>3

At the risk of surely sounding like a newfag, no idea what HIBT means. I know how to make and use an empty for loop, but I can do the exact same thing with a while loop. I was just wondering if there was any significance in using a for(;;) in particular.

int counter = 0;

for(;;)
{
  if( something = x )
  {
     function();
     counter++;
  }

  etc....

  if( counter = 3 )
  {
     break;
  }
}

is the same as

int counter = 0;

while( counter < 3 )
{
  if( something = x )
  {
     function();
     counter++;
  }
 
  etc....
}

Name: Anonymous 2009-03-14 16:55

>>4

Hawaiian International Billfishing Tournament. Hope that clears things up.

Name: Anonymous 2009-03-14 16:59

>>4
newfag
back to /b/, please, and come back when you've learned to leave /b/ talk at /b/.

Name: Anonymous 2009-03-14 17:00

What is the purpose of an empty for(;;) loop? Can not the exact same thing be accomplished with a while loop?

Actually, come to think of it, what's the use of a for loop anyway? After all,
int i;
for (i = 0; i < 5; i++)
    some_shit();

corresponds to
int i = 0;
while (i < 5){
    some_shit();
    i++;
}

anyway?

Yes, a for(;;) is the same as while(1), but have you ever heard of such a thing as personal taste? I prefer a while(1) myself, but plenty of people prefer for(;;)IHBT

Name: Anonymous 2009-03-14 17:03

for(;;) is awesome because you can verbally read it as a "forever" loop.

Name: Anonymous 2009-03-14 17:04

>>7
Yes, a for(;;) is the same as while(1)
No, for(;;) avoids checking that 1 is true.  (Some compilers are said to not optimize that away.)

>>4
while( counter < 3 )
for(;;) is primarily used for infinite loops.

Name: Anonymous 2009-03-14 17:08

(Some compilers are said to not optimize that away.)
Let me guess... GCC?

Name: Anonymous 2009-03-14 17:24

>>10
I don't think so.  Hmm... I'll have to Google this for a while and run some tests.

Name: Anonymous 2009-03-14 17:25

>>6
newfag

You should follow your own advice and go
back to /b/, please.
Just for using that term.

Name: Anonymous 2009-03-14 17:26

>>10
lc.exe

Name: Anonymous 2009-03-14 17:27

>>11
GCC outputs the same code for both at least.

Name: Anonymous 2009-03-14 17:43

>>9
counter <3

Name: Anonymous 2009-03-14 17:46

>>15
lol

Name: Anonymous 2009-03-14 17:55

$ cat for.c while.c; gcc -o for for.c; gcc -o while while.c; md5sum for while
int main() {
    for(;;) {}
}

int main() {
    while(1) {}
}

a55c6aa7cc5eef4a794f2e64a4e8abcb  for
a55c6aa7cc5eef4a794f2e64a4e8abcb  while

Name: Anonymous 2009-03-14 18:06

what is this loop you talk about?

I use goto

Name: Anonymous 2009-03-14 18:07

>>18
enjoy your spaghetti code

Name: Anonymous 2009-03-14 18:10

>>19
I will, along with my sauce.

Name: Anonymous 2009-03-14 18:18

>>20
Don't forget to optimize your meatballs!

Name: Anonymous 2009-03-14 23:05

Why is everyone in /prog/ a faggot? 20 posts and nobody explains what the acronym meant, meanwhile whining about /b/(the very reason this board has any users FYI). 
IHBT= I have been trolled
YHBT= You have been trolled
HIBT= Have I been trolled?
etc.
It was assumed you know what this meant because this is a very common expression around /prog/. Since for some reason many people feel the need to troll up /prog/(probably since 4chan and /b/ are the troll hotspots of the internet).  The majority of threads here are some form of obvious trolling/copypasta/spam.  Even if the thread is legitimate, it quickly gets over-run by trolls and spammers who endlessly repeat stupid unfunny memes.  Excuse my ranting, I just wish /prog/ didn't suck so much.  Some light moderation and the removal of all but the "code" bbcode tag could quickly put an end to the worst of it and allow actual discussion.

Name: Anonymous 2009-03-14 23:09

>>22
>/prog/
>actual discussion.

Name: Anonymous 2009-03-14 23:25

>>22
Look, fuck you. The fact that you don't know how /prog/ works does not constitute a problem. Most of the actual programming discussion happens in the IRC channels we've spawned and that's fine. In the mean time, the rest of us would like to make sure our shibboleths are maintained so we can continue to have productive discussion in said channels.

Name: Anonymous 2009-03-15 0:13

>>24
We have IRC channels?

Name: Anonymous 2009-03-15 1:31

>>25
#4chan@rizon
Nothing else exists.

Name: Anonymous 2009-03-15 1:51

>>22
While it is true that a number of us are /b/ expats, don't believe that we (the /b/ expats) appreciate it when other /b/tards come to spread their cancer. We don't care if this board's population stagnates or not. We care more for the segregation between the cancer and us.

Name: Anonymous 2009-03-15 4:07

I'd have to agree with >22 on some points. I myself have noticed a decrease in the quality of /prog/ as of late.

Name: Anonymous 2009-03-15 5:48

#sicp@synirc

Name: Anonymous 2009-03-15 8:16

>>28
Just as planned.

Name: Anonymous 2009-03-15 11:27

#bbcode@rizon

Name: Anonymous 2009-03-15 12:27

>>28
People have been saying that for years and it's only ever been true twice. Now that FrozenVirgin is either gone or hiding, quality is back on the increase.

Name: Anonymous 2009-03-15 14:49

>>32
Ah! You're right. The board is just going through a dark cycle right now. I'm hoping it will end soon and return to glory.

Name: Anonymous 2009-03-15 19:05

for(;;) doesn't give C4127: conditional expression is constant

Name: Anonymous 2009-03-15 19:52

>>31
People have been saying that for years and it's only ever been true twice

Name: Anonymous 2009-03-16 4:28

Here he comes, here comes speedracer,
HE'S A DEMON ON WHEELS

Name: Anonymous 2009-03-16 4:30

Here he comes, here comes speedracer,
HE'S A DEMON ON WHEELS

Name: Anonymous 2009-03-16 4:31

Here he comes, here comes speedracer,
HE'S A DEMON ON WHEELS

Name: Anonymous 2009-03-16 4:32

Here he comes, here comes speedracer,
HE'S A DEMON ON WHEELS

Name: Anonymous 2009-03-16 6:33

>>34
Oh wow, I thought this was a joke, but it's true.

http://msdn.microsoft.com/en-us/library/6t66728h(VS.80).aspx

What the fuck is wrong with them?

Name: Anonymous 2009-03-16 7:25

>>40
They couldn't properly debug their compiler, so instead they advise you to work-around the warnings. Priceless.

Name: Anonymous 2009-03-16 8:19

>>40
-fno-stupid-warnings

Name: Anonymous 2010-12-17 1:40

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-01-31 19:48

<-- check em dubz

Don't change these.
Name: Email:
Entire Thread Thread List