Call-by-Reference

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • coolguyaroundyou@gmail.com

    Call-by-Reference

    Does C have Call-By-Reference for a function??

    I think it doesn't. Am I right?
  • coolguyaroundyou@gmail.com

    #2
    Re: Call-by-Reference

    Technically speaking, does C have Call-By-Reference for a function??
    I think it doesn't. Am I right?

    Comment

    • Eric Sosman

      #3
      Re: Call-by-Reference

      coolguyaroundyo u@gmail.com wrote:
      Technically speaking, does C have Call-By-Reference for a function??
      I think it doesn't. Am I right?
      You are right: C function arguments are passed by value.

      An argument value can, of course, be a pointer -- that is,
      the argument value can refer to another object. But the
      argument itself is always passed by value.

      --
      Eric Sosman
      esosman@ieee-dot-org.invalid

      Comment

      • Keith Thompson

        #4
        Re: Call-by-Reference

        coolguyaroundyo u@gmail.com writes:
        Does C have Call-By-Reference for a function??
        Not directly, no; all parameters are passed by value. But of course
        you can do the equivalent by passing pointers.

        --
        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
        Nokia
        "We must do something. This is something. Therefore, we must do this."
        -- Antony Jay and Jonathan Lynn, "Yes Minister"

        Comment

        • Michael

          #5
          Re: Call-by-Reference

          coolguyaroundyo u@gmail.com wrote:
          Does C have Call-By-Reference for a function??
          >
          I think it doesn't. Am I right?
          There is no call-by reference in C but
          int func(int&a);
          is call-by-reference in c++

          Comment

          • Richard Heathfield

            #6
            Re: Call-by-Reference

            Michael said:
            coolguyaroundyo u@gmail.com wrote:
            >Does C have Call-By-Reference for a function??
            >>
            >I think it doesn't. Am I right?
            There is no call-by reference in C but
            int func(int&a);
            is call-by-reference in c++
            No, in C++ it's a declaration, not a call of any kind. And in C, it's just
            a syntax error.

            --
            Richard Heathfield <http://www.cpax.org.uk >
            Email: -http://www. +rjh@
            Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
            "Usenet is a strange place" - dmr 29 July 1999

            Comment

            • Nick Keighley

              #7
              Re: Call-by-Reference

              On 9 Nov, 18:53, Eric Sosman <esos...@ieee-dot-org.invalidwrot e:
              coolguyaround.. .@gmail.com wrote:
              Technically speaking, does C have Call-By-Reference for a function??
              I think it doesn't. Am I right?
              >
                   You are right: C function arguments are passed by value.
              you mean "wrong"?
              >
                   An argument value can, of course, be a pointer -- that is,
              the argument value can refer to another object.  But the
              argument itself is always passed by value.

              --
              Nick Keighley

              Comment

              • Richard Heathfield

                #8
                Re: Call-by-Reference

                Nick Keighley said:
                On 9 Nov, 18:53, Eric Sosman <esos...@ieee-dot-org.invalidwrot e:
                >coolguyaround. ..@gmail.com wrote:
                Technically speaking, does C have Call-By-Reference for a function??
                I think it doesn't. Am I right?
                >>
                >You are right: C function arguments are passed by value.
                >
                you mean "wrong"?
                No, he means "right", and he's right to mean that. The OP said he thinks
                that C *doesn't* have call by reference. First, he asked whether it did,
                and then he said he thinks not. He's right.

                --
                Richard Heathfield <http://www.cpax.org.uk >
                Email: -http://www. +rjh@
                Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                "Usenet is a strange place" - dmr 29 July 1999

                Comment

                • Dik T. Winter

                  #9
                  Re: Call-by-Reference

                  In article <ln8wrsyba0.fsf @nuthaus.mib.or gKeith Thompson <kst-u@mib.orgwrites :
                  coolguyaroundyo u@gmail.com writes:
                  Does C have Call-By-Reference for a function??
                  >
                  Not directly, no; all parameters are passed by value. But of course
                  you can do the equivalent by passing pointers.
                  That is not the same as call by reference. With call by reference the
                  only place where you actually can *see* it is call by reference is in
                  the header of a function. Not in the body, nor in the actual call.
                  --
                  dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
                  home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/

                  Comment

                  • Keith Thompson

                    #10
                    Re: Call-by-Reference

                    "Dik T. Winter" <Dik.Winter@cwi .nlwrites:
                    In article <ln8wrsyba0.fsf @nuthaus.mib.or gKeith Thompson
                    <kst-u@mib.orgwrites :
                    coolguyaroundyo u@gmail.com writes:
                    Does C have Call-By-Reference for a function??
                    >
                    Not directly, no; all parameters are passed by value. But of course
                    you can do the equivalent by passing pointers.
                    >
                    That is not the same as call by reference. With call by reference the
                    only place where you actually can *see* it is call by reference is in
                    the header of a function. Not in the body, nor in the actual call.
                    Yes, I know it's not the same thing, but it can be used to achieve
                    exactly the same effect.

                    --
                    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                    Nokia
                    "We must do something. This is something. Therefore, we must do this."
                    -- Antony Jay and Jonathan Lynn, "Yes Minister"

                    Comment

                    • CBFalconer

                      #11
                      Re: Call-by-Reference

                      Nick Keighley wrote:
                      Eric Sosman <esos...@ieee-dot-org.invalidwrot e:
                      >coolguyaround. ..@gmail.com wrote:
                      >>
                      >>Technically speaking, does C have Call-By-Reference for a
                      >>function?? I think it doesn't. Am I right?
                      >>
                      >You are right: C function arguments are passed by value.
                      >
                      you mean "wrong"?
                      No, you are wrong. The normal reading is handled by "C function
                      arguments are passed by value". The off-beat reading is handled by
                      the fact that C does NOT have "Call-By-Reference".

                      A third possible reading is that you are asserting "C function
                      arguments are passed by wrong".

                      :-) (and you are wrong)

                      --
                      [mail]: Chuck F (cbfalconer at maineline dot net)
                      [page]: <http://cbfalconer.home .att.net>
                      Try the download section.

                      Comment

                      • Eric Sosman

                        #12
                        Re: Call-by-Reference

                        Nick Keighley wrote:
                        On 9 Nov, 18:53, Eric Sosman <esos...@ieee-dot-org.invalidwrot e:
                        >coolguyaround. ..@gmail.com wrote:
                        >>Technically speaking, does C have Call-By-Reference for a function??
                        >>I think it doesn't. Am I right?
                        > You are right: C function arguments are passed by value.
                        >
                        you mean "wrong"?
                        If I remember right, I didn't mean "wrong" -- but I could be
                        wrong, right?

                        Two wrongs don't make a right, but three lefts do.

                        --
                        Eric.Sosman@sun .com

                        Comment

                        • jameskuyper

                          #13
                          Re: Call-by-Reference

                          Eric Sosman wrote:
                          ....
                          Two wrongs don't make a right, but three lefts do.
                          I miss street grids! Where I currently live, three left turns often
                          get me on a dead-end street, and usually get me lost - they are seldom
                          the equivalent of a right turn.

                          Comment

                          • CBFalconer

                            #14
                            Re: Call-by-Reference

                            jameskuyper wrote:
                            Eric Sosman wrote:
                            ...
                            >Two wrongs don't make a right, but three lefts do.
                            >
                            I miss street grids! Where I currently live, three left turns
                            often get me on a dead-end street, and usually get me lost -
                            they are seldom the equivalent of a right turn.
                            You are allowed to move out of Boston. :-)

                            --
                            [mail]: Chuck F (cbfalconer at maineline dot net)
                            [page]: <http://cbfalconer.home .att.net>
                            Try the download section.

                            Comment

                            • Joachim Schmitz

                              #15
                              Re: Call-by-Reference

                              jameskuyper wrote:
                              Eric Sosman wrote:
                              ...
                              > Two wrongs don't make a right, but three lefts do.
                              >
                              I miss street grids! Where I currently live, three left turns often
                              get me on a dead-end street, and usually get me lost - they are seldom
                              the equivalent of a right turn.
                              where I live 3 rights re likely to make a left, but three lefts will, on
                              average, get you in trouble with the police twice...

                              Bye, Jojo


                              Comment

                              Working...