Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. True that

True that

Scheduled Pinned Locked Moved The Weird and The Wonderful
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arthur F Souza
    wrote on last edited by
    #1

    A friend of mine wrote this little pearl a while ago. When I took the keyboard and wrote "true", we laughed for a good 5 mins. ...the next step was getting rid of the crazy infinite loop.

    while(Convert.ToBoolean(1))
    {
    // do stuff
    }

    R I 2 Replies Last reply
    0
    • A Arthur F Souza

      A friend of mine wrote this little pearl a while ago. When I took the keyboard and wrote "true", we laughed for a good 5 mins. ...the next step was getting rid of the crazy infinite loop.

      while(Convert.ToBoolean(1))
      {
      // do stuff
      }

      R Offline
      R Offline
      RobCroll
      wrote on last edited by
      #2

      while(true) is one of my pet hates.

      "You get that on the big jobs."

      F 1 Reply Last reply
      0
      • R RobCroll

        while(true) is one of my pet hates.

        "You get that on the big jobs."

        F Offline
        F Offline
        Firo Atrum Ventus
        wrote on last edited by
        #3

        Why?

        Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D

        R 1 Reply Last reply
        0
        • F Firo Atrum Ventus

          Why?

          Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D

          R Offline
          R Offline
          RobCroll
          wrote on last edited by
          #4

          while(true) isn't self-documenting

          while(true)
          {
          .... lots of code
          if(drunk) break;
          drinkBeer();
          .... lots more code
          }

          I much prefer

          while(!drunk)
          {
          .... lots of code
          drunk = true;
          if(drunk) continue;

          drinkBeer();
          .... lots more code
          }

          Although its probably just the drink beer bit I really like :)

          "You get that on the big jobs."

          F 1 Reply Last reply
          0
          • R RobCroll

            while(true) isn't self-documenting

            while(true)
            {
            .... lots of code
            if(drunk) break;
            drinkBeer();
            .... lots more code
            }

            I much prefer

            while(!drunk)
            {
            .... lots of code
            drunk = true;
            if(drunk) continue;

            drinkBeer();
            .... lots more code
            }

            Although its probably just the drink beer bit I really like :)

            "You get that on the big jobs."

            F Offline
            F Offline
            Firo Atrum Ventus
            wrote on last edited by
            #5

            RobCroll wrote:

            while(true) isn't self-documenting

            Guess that's where comments comes in handy.

            RobCroll wrote:

            while(true)
            {
            .... lots of code
            if(drunk) break;
            drinkBeer();
            .... lots more code
            }

            I much prefer

            while(!drunk)
            {
            .... lots of code
            drunk = true;
            if(drunk) continue;
             
            drinkBeer();
            .... lots more code
            }

            I'm a fan of while(true) but the first is simply garbage, I never used it like that.

            Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D

            R 1 Reply Last reply
            0
            • F Firo Atrum Ventus

              RobCroll wrote:

              while(true) isn't self-documenting

              Guess that's where comments comes in handy.

              RobCroll wrote:

              while(true)
              {
              .... lots of code
              if(drunk) break;
              drinkBeer();
              .... lots more code
              }

              I much prefer

              while(!drunk)
              {
              .... lots of code
              drunk = true;
              if(drunk) continue;
               
              drinkBeer();
              .... lots more code
              }

              I'm a fan of while(true) but the first is simply garbage, I never used it like that.

              Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D

              R Offline
              R Offline
              RobCroll
              wrote on last edited by
              #6

              You've got my interested now. So how do you use while(true) without coding garbage like break; (or return)?

              "You get that on the big jobs."

              F 1 Reply Last reply
              0
              • R RobCroll

                You've got my interested now. So how do you use while(true) without coding garbage like break; (or return)?

                "You get that on the big jobs."

                F Offline
                F Offline
                Firo Atrum Ventus
                wrote on last edited by
                #7

                No, no, don't misunderstand me. I use break;, continue;(above loop) or return; It's the context that I disagree with (ie. if you can make it simple with just a boolean, why do you need a while(true)?).

                Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D

                1 Reply Last reply
                0
                • A Arthur F Souza

                  A friend of mine wrote this little pearl a while ago. When I took the keyboard and wrote "true", we laughed for a good 5 mins. ...the next step was getting rid of the crazy infinite loop.

                  while(Convert.ToBoolean(1))
                  {
                  // do stuff
                  }

                  I Offline
                  I Offline
                  ii_noname_ii
                  wrote on last edited by
                  #8

                  I actually have a LOT of While 1=1 in MS SQL... It's very cool, works great, and I just love to see the face of programmers when I show them with pride my nested while 1=1 loops in recursive stored procs... ;P

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups