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

while is bad

Name: Anonymous 2010-01-11 13:51

Just thought I'd warn you, don't use while(1)
It is INCREDIBLY DANGEROUS

http://ubuntuforums.org/showpost.php?p=805826&postcount=10

Name: Anonymous 2010-01-11 13:59

while loops are only dangerous if you're a moron.

Name: Anonymous 2010-01-11 14:00

Lol'd

BTW, why didn't anyone make a language with a loop construct which checks the condition in the middle of the loop? Like

{
  char *pos = strchr(str, old);
} while(pos) {
  *pos = new;
}

Name: Anonymous 2010-01-11 14:02

LOLLING AT BEST-PRACTICE MICRO-DICK

Name: Anonymous 2010-01-11 14:02

Thinks that people don't want infinite loops

Name: Anonymous 2010-01-11 14:09

Way to reference a five-year-old thread, jerkface.

Second, this function only replaces the first occurence of the char, not all of them.
so yeah, his a retard.  but the loop is infinite if old == new (and occurs in the string).  and it loops until segfault on old == 0.  and its inefficient.

Name: Anonymous 2010-01-11 15:05

POTENTIAL INFINITE LOOPS!!1

Name: Anonymous 2010-01-11 15:36

I use unless.

Name: Anonymous 2010-01-11 17:08

>>3
A question for the ages. The “n + ½” loop pattern was recognized as early as 1967, see Wirth's “On certain basic concepts of programming languages”1 and Knuth's “Structured Programming with Goto Statements”2. The reason one of the suggested solutions wasn't broadly adopted is probably that existing syntax like break and sequencing in the condition is not that bad.

1 ftp://db.stanford.edu/pub/cstr/reports/cs/tr/67/65/CS-TR-67-65.pdf
2 http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf

Name: Anonymous 2010-01-11 18:25

>>9
I remember reading about Knuth asking that question. Thanks for the literature!
Yeah, implementing a new loop type with a few more keywords wouldn't really serve a purpose, and there isn't a clear syntactical way of doing this.
You could always #define unless(p) if (!(p)) break;, or even change unless to insure if you feel like it.

Name: Anonymous 2010-01-11 18:36

>>10

But what about ensure?

Name: Anonymous 2010-01-11 19:14

>>11
ENSURE MY ANUS

Name: Anonymous 2010-01-11 19:26

>>11
Sorry, bud, no way.

Name: Anonymous 2010-01-11 22:58

>>3
Blizzard's "jass" scripting language for Warcraft 3 maps has such a construct. It might even have been attractive if it weren't the only way to control a loop and if the language weren't PIG DISGUSTING for many other reasons anyway.

Name: Anonymous 2010-01-12 0:35

void participate(BBThread *thread)
{
   if(!thread->sucks)
   {
      *thread->sucks= true;
   }
   while(*thread->sucks)
   {
      post(*thread, "Sage.\n");
   }
   post(*thread, "This thread sucks.\n");
   *thread->sucks = true;
   participate(*thread);
}

Name: Anonymous 2010-01-12 1:53

>>14
Yeah!

Name: Anonymous 2010-01-12 10:56

That's like saying recursion is dangerous because of potential for stack overflows(tail-recursion can lead to loops, thus according to OP is dangerous too). Oh wait, the language wouldn't be touring complete if you couldn't loop. Thus all programming is dangerous.

Name: Anonymous 2010-01-12 13:21

Programming is dangerous.

Name: Anonymous 2013-01-19 20:57

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

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