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. The Lounge
  3. Thought about programming

Thought about programming

Scheduled Pinned Locked Moved The Lounge
questiondiscussiontutorial
61 Posts 18 Posters 6 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.
  • C Chris Losinger

    pair will get you 2. how do you do 3, 10 or 50? -c


    There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'. --Holgate, from Plastic

    Smaller Animals Software

    N Offline
    N Offline
    Neville Franks
    wrote on last edited by
    #20

    Chris Losinger wrote: pair will get you 2. how do you do 3, 10 or 50? I thought he only wanted 2. Someone else mentioned boost tupples. In my vast experience a pair is the most common requirement here by far.:) Neville Franks, Author of ED for Windows. www.getsoft.com Make money with our new Affilate program

    J 1 Reply Last reply
    0
    • C Chris Losinger

      pair will get you 2. how do you do 3, 10 or 50? -c


      There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'. --Holgate, from Plastic

      Smaller Animals Software

      T Offline
      T Offline
      Tim Smith
      wrote on last edited by
      #21

      std::vector :omg::rolleyes::laugh: Tim Smith I'm going to patent thought. I have yet to see any prior art.

      C J 2 Replies Last reply
      0
      • T Tim Smith

        Yup, sounds good. Only would need it once in a blue moon. I would rather have the compiler vendors spending time working on a better compiler than the standards group sitting around trying to justify their existence. IMHO, C/C++ has really come to the end of their extensible lifetime. It really needs to be rebuilt from the ground up and not have new features just hacked onto it. Tim Smith I'm going to patent thought. I have yet to see any prior art.

        C Offline
        C Offline
        CodeGuy
        wrote on last edited by
        #22

        Tim Smith wrote: IMHO, C/C++ has really come to the end of their extensible lifetime. It really needs to be rebuilt from the ground up and not have new features just hacked onto it. Hear, hear. Brandon

        T 1 Reply Last reply
        0
        • C CodeGuy

          Tim Smith wrote: IMHO, C/C++ has really come to the end of their extensible lifetime. It really needs to be rebuilt from the ground up and not have new features just hacked onto it. Hear, hear. Brandon

          T Offline
          T Offline
          Tim Smith
          wrote on last edited by
          #23

          LOL... Sometimes it is more scary where people agree with me. :eek: Tim Smith I'm going to patent thought. I have yet to see any prior art.

          1 Reply Last reply
          0
          • S Shog9 0

            Chris Losinger wrote: both are forcing you to work around limitations of the language. Well, yeah, and C# lets you do properties with get and set methods automatically called at appropriate times. But how much of this is a big advantage? Can you provide an example where code clarity is increased significantly by being able to return two values?

            ---

            Shog9 Life seems pretty easy when it's from my easy chair And you're burnin up inside and no one cares...

            F Offline
            F Offline
            Fazlul Kabir
            wrote on last edited by
            #24

            Shog9 wrote: C# lets you do properties with get and set methods automatically called at appropriate times. But how much of this is a big advantage? I think "properties" let us write code in a more "human readable" fashion. Compare the two sets of statements below: myForm.BackColor = red; Color clr = myForm.BackColor; and myForm.setBackColor(red); Color clr = myForm.getBackColor(); But I agree, these choices are merely based on convenience, that's all.

            1 Reply Last reply
            0
            • T Tim Smith

              std::vector :omg::rolleyes::laugh: Tim Smith I'm going to patent thought. I have yet to see any prior art.

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

              laugh it up... what if you want to return 7 values, not all the same type? A: a "struct" is a workaround.


              There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'. --Holgate, from Plastic

              Smaller Animals Software

              T 1 Reply Last reply
              0
              • J Jamie Nordmeyer

                This is not a question about how to do something, per say, but is a question of opinion. Still, if anyone feels this post is ill placed, let me know, and I'll move it. :) I noticed a language on SourceForget the other day called Nice, that had an interesting feature called Tuples. Essentially, it allowed you to do this:

                (int, int) FooBar()
                {
                return 5, 10;
                }

                My question is what do you think about this in a language. Most of our languages have thus far only supported a single return value, where as Nice allows an arbitrary number of values to be returned. Thoughts? Jamie Nordmeyer Portland, Oregon, USA

                T Offline
                T Offline
                Tomas Petricek
                wrote on last edited by
                #26

                This looks nice but how do i call this function ? (int, int) a=FooBar(); //?? int b=a??+a??; :confused: i'm only pointer to myself

                J 1 Reply Last reply
                0
                • S Shog9 0

                  Colin Davies wrote: The best way to find out how useful something is, isn't to add it, but to remove it. True, that. :) One of the things i miss most in VB are C's +=, *=, &= etc. operators... Never something i would have wanted prior to using C, but sure conspicuous when absent now...!

                  ---

                  Shog9 Life seems pretty easy when it's from my easy chair And you're burnin up inside and no one cares...

                  N Offline
                  N Offline
                  Nick Parker
                  wrote on last edited by
                  #27

                  Shog9 wrote: One of the things i miss most in VB are C's +=, *=, &= etc. operators... Sadly I miss those as well.


                  Nick Parker

                  Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein

                  J 1 Reply Last reply
                  0
                  • C Chris Losinger

                    laugh it up... what if you want to return 7 values, not all the same type? A: a "struct" is a workaround.


                    There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'. --Holgate, from Plastic

                    Smaller Animals Software

                    T Offline
                    T Offline
                    Tim Smith
                    wrote on last edited by
                    #28

                    That is what the VARIANT was for. :) Tim Smith I'm going to patent thought. I have yet to see any prior art.

                    C 1 Reply Last reply
                    0
                    • T Tim Smith

                      That is what the VARIANT was for. :) Tim Smith I'm going to patent thought. I have yet to see any prior art.

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

                      ah.. the VARIANT. the deepest chasm in the Valley of Dangerous Practices. i fear the VARIANT and all its evil offspring. nothing but pain and suffering down that road.


                      There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'. --Holgate, from Plastic

                      Smaller Animals Software

                      J 1 Reply Last reply
                      0
                      • J Jamie Nordmeyer

                        This is not a question about how to do something, per say, but is a question of opinion. Still, if anyone feels this post is ill placed, let me know, and I'll move it. :) I noticed a language on SourceForget the other day called Nice, that had an interesting feature called Tuples. Essentially, it allowed you to do this:

                        (int, int) FooBar()
                        {
                        return 5, 10;
                        }

                        My question is what do you think about this in a language. Most of our languages have thus far only supported a single return value, where as Nice allows an arbitrary number of values to be returned. Thoughts? Jamie Nordmeyer Portland, Oregon, USA

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

                        People will start doing something like "(int, (int, int)) FooBar, and end up as LISP programmers with the wrong compiler.


                        If I could find a souvenir / just to prove the world was here   [sighist]

                        J 1 Reply Last reply
                        0
                        • C Chris Losinger

                          Shog9 wrote: Eh, what's wrong with... both are forcing you to work around limitations of the language. what you really want to do is "return 2 values". it's similar to the way you can do "OO" in plain C by clever use of function pointers and structures to simulate objects. but, it's nothing like C++, where OO is built-in. -c


                          There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'. --Holgate, from Plastic

                          Smaller Animals Software

                          J Offline
                          J Offline
                          Jamie Nordmeyer
                          wrote on last edited by
                          #31

                          Well put, Chris. Zat's what I was thinking. Jamie Nordmeyer Portland, Oregon, USA

                          1 Reply Last reply
                          0
                          • N Nick Parker

                            Shog9 wrote: One of the things i miss most in VB are C's +=, *=, &= etc. operators... Sadly I miss those as well.


                            Nick Parker

                            Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein

                            J Offline
                            J Offline
                            Jamie Nordmeyer
                            wrote on last edited by
                            #32

                            Well, most of the users on here use C#, but VB.NET has included these operators. Unfortunately, ++ and -- aren't used (why, I don't know), and you can't overload them. Doh!!! Jamie Nordmeyer Portland, Oregon, USA

                            N 1 Reply Last reply
                            0
                            • J Jamie Nordmeyer

                              Well, most of the users on here use C#, but VB.NET has included these operators. Unfortunately, ++ and -- aren't used (why, I don't know), and you can't overload them. Doh!!! Jamie Nordmeyer Portland, Oregon, USA

                              N Offline
                              N Offline
                              Nick Parker
                              wrote on last edited by
                              #33

                              Jamie Nordmeyer wrote: Well, most of the users on here use C#, but VB.NET has included these operators. Unfortunately, ++ and -- aren't used (why, I don't know), and you can't overload them. Doh!!! I know, as am I. I have only used VB.NET a few times, only enough to answer a few questions in their forum.


                              Nick Parker

                              Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein

                              1 Reply Last reply
                              0
                              • N Neville Franks

                                Chris Losinger wrote: pair will get you 2. how do you do 3, 10 or 50? I thought he only wanted 2. Someone else mentioned boost tupples. In my vast experience a pair is the most common requirement here by far.:) Neville Franks, Author of ED for Windows. www.getsoft.com Make money with our new Affilate program

                                J Offline
                                J Offline
                                Jamie Nordmeyer
                                wrote on last edited by
                                #34

                                But using a Tuple object, we're still returning only 1 value... an object. The idea of the tuple as presented in Nice is that you're physically returning 2, 3, or n number of values. You're not wrapping them in an object to fake it, you're physically passing back an int, and then a float, or whatever. Jamie Nordmeyer Portland, Oregon, USA

                                J 1 Reply Last reply
                                0
                                • C Chris Losinger

                                  ah.. the VARIANT. the deepest chasm in the Valley of Dangerous Practices. i fear the VARIANT and all its evil offspring. nothing but pain and suffering down that road.


                                  There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'. --Holgate, from Plastic

                                  Smaller Animals Software

                                  J Offline
                                  J Offline
                                  Jamie Nordmeyer
                                  wrote on last edited by
                                  #35

                                  I haven't thought about Variants since I started using .NET. Now, to have them return to my memory... AAAAARRRRGGGHHH!!!! :omg::omg::omg::wtf::wtf::wtf: :-D Jamie Nordmeyer Portland, Oregon, USA

                                  1 Reply Last reply
                                  0
                                  • T Tomas Petricek

                                    This looks nice but how do i call this function ? (int, int) a=FooBar(); //?? int b=a??+a??; :confused: i'm only pointer to myself

                                    J Offline
                                    J Offline
                                    Jamie Nordmeyer
                                    wrote on last edited by
                                    #36

                                    I think it'd be something like:

                                    int a, b;

                                    (a, b) = FooBar();

                                    Or maybe a special symbol other than parenthesis, perhaps brackets. Jamie Nordmeyer Portland, Oregon, USA

                                    J 1 Reply Last reply
                                    0
                                    • C Chris Losinger

                                      pair will get you 2. how do you do 3, 10 or 50? -c


                                      There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'. --Holgate, from Plastic

                                      Smaller Animals Software

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

                                      pair<,pair<,> > etc. :cool:


                                      If I could find a souvenir / just to prove the world was here   [sighist]

                                      J 1 Reply Last reply
                                      0
                                      • S Shog9 0

                                        Eh, what's wrong with:

                                        struct blah_t { int i; int j; };
                                        blah_t FooBar()
                                        {
                                        blah_t ret = {5,10};
                                        return ret;
                                        }

                                        or for that matter,

                                        void FooBar(int& i, int &j)
                                        {
                                        i = 5; j = 10;
                                        }

                                        Granted, Nice sounds concise, but it seems unnecessary given how often such a thing is necessary.

                                        ---

                                        Shog9 Life seems pretty easy when it's from my easy chair And you're burnin up inside and no one cares...

                                        C Offline
                                        C Offline
                                        Christian Skovdal Andersen
                                        wrote on last edited by
                                        #38

                                        Option one makes you perform a copy of the data, which is always expensive. The compiler may be capable of optimizing the copy away though -any thoughts? Christian Skovdal Andersen Don't mention the war...

                                        1 Reply Last reply
                                        0
                                        • S Shog9 0

                                          Eh, what's wrong with:

                                          struct blah_t { int i; int j; };
                                          blah_t FooBar()
                                          {
                                          blah_t ret = {5,10};
                                          return ret;
                                          }

                                          or for that matter,

                                          void FooBar(int& i, int &j)
                                          {
                                          i = 5; j = 10;
                                          }

                                          Granted, Nice sounds concise, but it seems unnecessary given how often such a thing is necessary.

                                          ---

                                          Shog9 Life seems pretty easy when it's from my easy chair And you're burnin up inside and no one cares...

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

                                          Shog9 wrote: Granted, Nice sounds concise, but it seems unnecessary given how often such a thing is necessary. It happens enough to be annoying. I usually use std::pair or one of my handcrafter stdex::triplet, std::quadruplet, etc. Maybe I should start using boost for this too. :) -- This space for rent.

                                          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