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 Back Room
  4. forophobia

forophobia

Scheduled Pinned Locked Moved The Back Room
questionc++linqdockeralgorithms
26 Posts 16 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.
  • P peterchen

    Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

    // deprecated, don't use:
    // for(int i=0; i

    I tell you what: unless I can write

    count_if(container, element > 0)

    I stick with my loops.

    Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

    I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

    The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

    It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

    What can go wrong in a loop?

    • you forget to increment
    • you are off by one
    • you invalidate the container or the iterator

    The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

    How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

    Introducing a generic container iteration syntax ("a container to be iterable must have b

    J Offline
    J Offline
    Jorgen Sigvardsson
    wrote on last edited by
    #2

    std::for_each(peterchen_rant_post_about_stl_algorithms.begin(), peterchen_rant_post_about_stl_algorithms.end(), tease()); ;P :-D I like both loops and algorithms. Sometimes the loop is better to solve the problem, and sometimes the algorithm is better. I've noticed that if there's a well known/common pattern which you'd like to do on your items such as delete or ->Release(), algorithms + functors dominates - I just have to write the loop once and be done with it. Loops which do specialized work is of course best left alone, and I think that was the intent by the designers of STL & co as well. -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

    1 Reply Last reply
    0
    • P peterchen

      Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

      // deprecated, don't use:
      // for(int i=0; i

      I tell you what: unless I can write

      count_if(container, element > 0)

      I stick with my loops.

      Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

      I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

      The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

      It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

      What can go wrong in a loop?

      • you forget to increment
      • you are off by one
      • you invalidate the container or the iterator

      The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

      How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

      Introducing a generic container iteration syntax ("a container to be iterable must have b

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #3

      BTW, when I do iterator loops, I use while loops;

      container::iterator i = c.begin(), end = c.end();
      while(i != end) {
      // Do some funky stuff here
      ++i;
      }

      . The for loop tends to become very kludgy when you define 2 variables in its initialization part. :) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

      P P 2 Replies Last reply
      0
      • P peterchen

        Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

        // deprecated, don't use:
        // for(int i=0; i

        I tell you what: unless I can write

        count_if(container, element > 0)

        I stick with my loops.

        Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

        I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

        The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

        It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

        What can go wrong in a loop?

        • you forget to increment
        • you are off by one
        • you invalidate the container or the iterator

        The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

        How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

        Introducing a generic container iteration syntax ("a container to be iterable must have b

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #4

        i agree. after a certain point, trying to turn C++ into Haskell just creates confusion for anyone unfortunate enough to have to maintain the code. not everybody who knows C++ knows about boost tricks, but everybody who knows C++ knows what a for-loop does. Software | Cleek

        1 Reply Last reply
        0
        • J Jorgen Sigvardsson

          BTW, when I do iterator loops, I use while loops;

          container::iterator i = c.begin(), end = c.end();
          while(i != end) {
          // Do some funky stuff here
          ++i;
          }

          . The for loop tends to become very kludgy when you define 2 variables in its initialization part. :) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

          P Offline
          P Offline
          peterchen
          wrote on last edited by
          #5

          I'm actually trying to move on to an iterator pair, that acts like an iterator that knows it's end, so you can

          for(iterpair it(container); it; ++it)
          DoSomethingNastyTo(*it);

          Just got to roughen out the templates and make it an CP article... maybe tomnite - no, it rained the first time since weeksof a brutish heat. I'll have a walk down to the river.


          we are here to help each other get through this thing, whatever it is Vonnegut jr.
          sighist || Agile Programming | doxygen

          J 1 Reply Last reply
          0
          • P peterchen

            Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

            // deprecated, don't use:
            // for(int i=0; i

            I tell you what: unless I can write

            count_if(container, element > 0)

            I stick with my loops.

            Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

            I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

            The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

            It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

            What can go wrong in a loop?

            • you forget to increment
            • you are off by one
            • you invalidate the container or the iterator

            The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

            How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

            Introducing a generic container iteration syntax ("a container to be iterable must have b

            J Offline
            J Offline
            Jim A Johnson
            wrote on last edited by
            #6

            A agree. I've tried to get into the convoluted STL algorithm stuff, but the number of absurd hoops one has to jump through to use for_each just isn't worth the headache. I think the problem is that, like anything else, loops are dangerous in the hands of a stupid person. But all this solution does is to make replace one kind of potential error with a few more.. and with the resulting overhead of having to learn how the screwball STL algorithm syntax works.

            1 Reply Last reply
            0
            • P peterchen

              Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

              // deprecated, don't use:
              // for(int i=0; i

              I tell you what: unless I can write

              count_if(container, element > 0)

              I stick with my loops.

              Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

              I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

              The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

              It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

              What can go wrong in a loop?

              • you forget to increment
              • you are off by one
              • you invalidate the container or the iterator

              The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

              How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

              Introducing a generic container iteration syntax ("a container to be iterable must have b

              R Offline
              R Offline
              Rob Manderson
              wrote on last edited by
              #7

              What an excellent rant!! Got my 5 :) Rob Manderson I'm working on a version for Visual Lisp++

              1 Reply Last reply
              0
              • P peterchen

                Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

                // deprecated, don't use:
                // for(int i=0; i

                I tell you what: unless I can write

                count_if(container, element > 0)

                I stick with my loops.

                Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

                I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

                The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

                It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

                What can go wrong in a loop?

                • you forget to increment
                • you are off by one
                • you invalidate the container or the iterator

                The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

                How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

                Introducing a generic container iteration syntax ("a container to be iterable must have b

                J Offline
                J Offline
                jan larsen
                wrote on last edited by
                #8

                peterchen wrote: The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo! Hey,try to be a little sensitive man, there are logically challenged programmers too you know. I once met this loop written by an Oracle consultant:

                for (int i = 0; i < 1; i++)
                {
                // And here was 1 (one) line of code!...
                }

                He obviously hadn't consulted the Oracle the day he wrote that... "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus

                1 Reply Last reply
                0
                • P peterchen

                  Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

                  // deprecated, don't use:
                  // for(int i=0; i

                  I tell you what: unless I can write

                  count_if(container, element > 0)

                  I stick with my loops.

                  Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

                  I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

                  The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

                  It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

                  What can go wrong in a loop?

                  • you forget to increment
                  • you are off by one
                  • you invalidate the container or the iterator

                  The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

                  How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

                  Introducing a generic container iteration syntax ("a container to be iterable must have b

                  P Offline
                  P Offline
                  paulb
                  wrote on last edited by
                  #9

                  for loops are way too readable, the whole purpose of STL and especially Boost is to enable the production of completely unreadable code that will utterly confuse the slack-jawed imbecile who only knows C# and is asked to maintain my C++ code. I plan to leave behind a legacy that will cause tears of frustration and untold misery in the so-called "programmers" of tommorrow.

                  C N I 3 Replies Last reply
                  0
                  • P paulb

                    for loops are way too readable, the whole purpose of STL and especially Boost is to enable the production of completely unreadable code that will utterly confuse the slack-jawed imbecile who only knows C# and is asked to maintain my C++ code. I plan to leave behind a legacy that will cause tears of frustration and untold misery in the so-called "programmers" of tommorrow.

                    C Offline
                    C Offline
                    ColinDavies
                    wrote on last edited by
                    #10

                    paulb wrote: I plan to leave behind a legacy that will cause tears of frustration and untold misery in the so-called "programmers" of tommorrow. You definitly have the right attitude. Now for god-sake never comment any code, unless you learn Klingon. Regardz Colin J Davies Attention: Watch this signature for an upcoming announcement that will effect you.

                    K 1 Reply Last reply
                    0
                    • P peterchen

                      I'm actually trying to move on to an iterator pair, that acts like an iterator that knows it's end, so you can

                      for(iterpair it(container); it; ++it)
                      DoSomethingNastyTo(*it);

                      Just got to roughen out the templates and make it an CP article... maybe tomnite - no, it rained the first time since weeksof a brutish heat. I'll have a walk down to the river.


                      we are here to help each other get through this thing, whatever it is Vonnegut jr.
                      sighist || Agile Programming | doxygen

                      J Offline
                      J Offline
                      Jorgen Sigvardsson
                      wrote on last edited by
                      #11

                      That's pretty smart! -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

                      1 Reply Last reply
                      0
                      • C ColinDavies

                        paulb wrote: I plan to leave behind a legacy that will cause tears of frustration and untold misery in the so-called "programmers" of tommorrow. You definitly have the right attitude. Now for god-sake never comment any code, unless you learn Klingon. Regardz Colin J Davies Attention: Watch this signature for an upcoming announcement that will effect you.

                        K Offline
                        K Offline
                        KaRl
                        wrote on last edited by
                        #12

                        ColinDavies wrote: for god-sake never comment any code, unless you learn Klingon :laugh::laugh::laugh: That's brilliant, I start from now.


                        Собой остаться дольше...

                        1 Reply Last reply
                        0
                        • P peterchen

                          Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

                          // deprecated, don't use:
                          // for(int i=0; i

                          I tell you what: unless I can write

                          count_if(container, element > 0)

                          I stick with my loops.

                          Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

                          I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

                          The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

                          It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

                          What can go wrong in a loop?

                          • you forget to increment
                          • you are off by one
                          • you invalidate the container or the iterator

                          The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

                          How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

                          Introducing a generic container iteration syntax ("a container to be iterable must have b

                          N Offline
                          N Offline
                          Nemanja Trifunovic
                          wrote on last edited by
                          #13

                          For your eyes only:

                          vector<pair<int, int> > v;
                          transform(x.begin(), x.end(), y.begin(), back_inserter(v),
                          bind(constructor<pair<int, int> >(), _1, _2));

                          :jig: :jig:


                          My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                          1 Reply Last reply
                          0
                          • P paulb

                            for loops are way too readable, the whole purpose of STL and especially Boost is to enable the production of completely unreadable code that will utterly confuse the slack-jawed imbecile who only knows C# and is asked to maintain my C++ code. I plan to leave behind a legacy that will cause tears of frustration and untold misery in the so-called "programmers" of tommorrow.

                            N Offline
                            N Offline
                            Nemanja Trifunovic
                            wrote on last edited by
                            #14

                            paulb wrote: slack-jawed imbecile who only knows C# and is asked to maintain my C++ code. Most VB C# programmers wouldn't come near any C++ code - they are too afraid of pointers. Pointers bite, you know.


                            My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                            P 1 Reply Last reply
                            0
                            • P peterchen

                              Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

                              // deprecated, don't use:
                              // for(int i=0; i

                              I tell you what: unless I can write

                              count_if(container, element > 0)

                              I stick with my loops.

                              Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

                              I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

                              The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

                              It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

                              What can go wrong in a loop?

                              • you forget to increment
                              • you are off by one
                              • you invalidate the container or the iterator

                              The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

                              How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

                              Introducing a generic container iteration syntax ("a container to be iterable must have b

                              M Offline
                              M Offline
                              Marc Clifton
                              wrote on last edited by
                              #15

                              peterchen wrote: What can go wrong in a loop? Well, apparently it was a loop that brought CP to its knees a few weeks ago. :-D Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net

                              P 1 Reply Last reply
                              0
                              • J Jorgen Sigvardsson

                                BTW, when I do iterator loops, I use while loops;

                                container::iterator i = c.begin(), end = c.end();
                                while(i != end) {
                                // Do some funky stuff here
                                ++i;
                                }

                                . The for loop tends to become very kludgy when you define 2 variables in its initialization part. :) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

                                P Offline
                                P Offline
                                Paul Watson
                                wrote on last edited by
                                #16

                                Then you forget the ++i;... regards, Paul Watson Bluegrass South Africa Christopher Duncan wrote: "I always knew that somewhere deep inside that likable, Save the Whales kinda guy there lurked the heart of a troublemaker..." Crikey! ain't life grand?

                                J 1 Reply Last reply
                                0
                                • N Nemanja Trifunovic

                                  paulb wrote: slack-jawed imbecile who only knows C# and is asked to maintain my C++ code. Most VB C# programmers wouldn't come near any C++ code - they are too afraid of pointers. Pointers bite, you know.


                                  My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                                  P Offline
                                  P Offline
                                  Paul Watson
                                  wrote on last edited by
                                  #17

                                  >Most VB C# programmers :mad: Let us not start more idiotic prejudice based on language choice eh. regards, Paul Watson Bluegrass South Africa Christopher Duncan wrote: "I always knew that somewhere deep inside that likable, Save the Whales kinda guy there lurked the heart of a troublemaker..." Crikey! ain't life grand?

                                  N P 2 Replies Last reply
                                  0
                                  • P Paul Watson

                                    >Most VB C# programmers :mad: Let us not start more idiotic prejudice based on language choice eh. regards, Paul Watson Bluegrass South Africa Christopher Duncan wrote: "I always knew that somewhere deep inside that likable, Save the Whales kinda guy there lurked the heart of a troublemaker..." Crikey! ain't life grand?

                                    N Offline
                                    N Offline
                                    Nemanja Trifunovic
                                    wrote on last edited by
                                    #18

                                    Paul Watson wrote: more idiotic prejudice based on language choice eh Hey, hey, hey! This is SoapBox. Why are political, religious and sexual prejudices better than programming ones? I have no opinion on gay marriages or affirmative action (whatever that is), so I am excluded from SoapBox? More programming rants to the people. :cool:


                                    My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                                    P 1 Reply Last reply
                                    0
                                    • N Nemanja Trifunovic

                                      Paul Watson wrote: more idiotic prejudice based on language choice eh Hey, hey, hey! This is SoapBox. Why are political, religious and sexual prejudices better than programming ones? I have no opinion on gay marriages or affirmative action (whatever that is), so I am excluded from SoapBox? More programming rants to the people. :cool:


                                      My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                                      P Offline
                                      P Offline
                                      Paul Watson
                                      wrote on last edited by
                                      #19

                                      Just ranting right back at ya. Give me what you can! :P regards, Paul Watson Bluegrass South Africa Christopher Duncan wrote: "I always knew that somewhere deep inside that likable, Save the Whales kinda guy there lurked the heart of a troublemaker..." Crikey! ain't life grand?

                                      1 Reply Last reply
                                      0
                                      • P peterchen

                                        Just read Andrew parkers nice boost intro. One sentence triggered a "prtogramiming question", with a line of thought better suited to this board: minimising the amount of times that users have to write their own loops Hello? Are we programmers or what? Look the framework we have to build to minimise (not remove, just "minimise") writing loops: iterators. const. unidirectional. bidirectional. reverse iterators. const or not. iterator adaptor. functors. binders. composers. bind. function. lambda library. anything I forgot? most likely. We need to templatize like hell, bending the compiler to a point where we are happy it makes it through our code alive - and when not, we don't dare ask for sensible error messages. To avoid what?

                                        // deprecated, don't use:
                                        // for(int i=0; i

                                        I tell you what: unless I can write

                                        count_if(container, element > 0)

                                        I stick with my loops.

                                        Where does this fear come from? It looks like everybody is ooohing and aaahing the marvelous insights into the human being Dr Freud opened up for all of us, wondering how we could live without it so long, before noticing that he's a serious whacko who needs some true job instead of a leather couch.

                                        I suspect one of the guys who miffed up the STL was seriously loopophobic. maybe his wife left him because of a loop. Maybe his child died in his arms because he was off by one. Maybe he saw his sister nekkid in the woods when he was five. We don't know. But he had something going. What would be necessary to eliminate loops? At least most of them? Mark them evil?

                                        The recent round of job interviews - complete with "write some code please": the majority rather try to remember an omnious function they once heard of (or just make one up that doesn't exist), instead of touching a for loop.

                                        It's a loop, for god's sake. It's not a bear trap, it's not the infamous goto-spaghetti mess, it's not a terrorist nuke we have to keep out of our code whatever sacrifice of sanity is necessary.

                                        What can go wrong in a loop?

                                        • you forget to increment
                                        • you are off by one
                                        • you invalidate the container or the iterator

                                        The first requires some discipline, the second some basic calculus training, and the third heaven forbid thinking! whoo!

                                        How many algorithms can you think of using a loop? Ten? Tenthousand? Guys, generalize looping, not the algorithm.

                                        Introducing a generic container iteration syntax ("a container to be iterable must have b

                                        J Offline
                                        J Offline
                                        Jeff Bogan
                                        wrote on last edited by
                                        #20

                                        Yeah that's my impression, too. This seems to be complexity for complexity's sake, or possibly just to distance itself from anything obvious non-STL. ----------------------------- All truth passes through 3 stages. First, it is ridiculed. Second, it is violently opposed. Third, it is accepted as being self-evident.

                                        1 Reply Last reply
                                        0
                                        • P paulb

                                          for loops are way too readable, the whole purpose of STL and especially Boost is to enable the production of completely unreadable code that will utterly confuse the slack-jawed imbecile who only knows C# and is asked to maintain my C++ code. I plan to leave behind a legacy that will cause tears of frustration and untold misery in the so-called "programmers" of tommorrow.

                                          I Offline
                                          I Offline
                                          Ian Darling
                                          wrote on last edited by
                                          #21

                                          paulb wrote: for loops are way too readable Not if you do something like this :-D

                                          #include <iostream>
                                          using namespace std;
                                          int arr[] = {3, 4, 2, 5, 1, 9, 0, 8, 7, 6 };
                                          for(int i=((signed)sizeof(arr)/-(signed)sizeof(arr[0]));cout<
                                          

                                          * * * Ian Darling [The world is a thing of utter inordinate complexity ... that such complexity can arise ... out of such simplicity ... is the most fabulous extraordinary idea ... once you get some kind of inkling of how that might have happened - it's just wonderful ... the opportunity to spend 70 or 80 years of your life in such a universe is time well spent as far as I am concerned](http://www.edge.org/documents/adams_index.html) - Douglas Adams

                                          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