call back functions...

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

    #1

    call back functions...

    I am looking for some comprehensive tutorials on how to write call
    back functions in C. Can anyone help me?

    - sameer oak.

  • Eric Sosman

    #2
    Re: call back functions...

    sameer.oak@gmai l.com wrote:
    I am looking for some comprehensive tutorials on how to write call
    back functions in C. Can anyone help me?
    Write a callback function in the same way you write
    any other function. There is nothing "different" about a
    callback function, nothing at all. It's just a function.

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

    Comment

    • Barry Schwarz

      #3
      Re: call back functions...

      On Thu, 28 Jun 2007 02:57:06 -0700, "sameer.oak@gma il.com"
      <sameer.oak@gma il.comwrote:
      >I am looking for some comprehensive tutorials on how to write call
      >back functions in C. Can anyone help me?
      >
      It depends on who is calling your function and what you want the
      function to do for them. Probably the simplest example is the compare
      function passed to qsort. There should be at least one example in
      your reference which will show you how to obtain the arguments passed
      as generic pointers and return a result. Anything else will require
      more detail from you.


      Remove del for email

      Comment

      • Carramba

        #4
        Re: call back functions...

        sameer.oak@gmai l.com skrev:
        I am looking for some comprehensive tutorials on how to write call
        back functions in C. Can anyone help me?
        >
        - sameer oak.
        >
        check here
        http://en.wikipedia.org/wiki/Callback_(computer_science)

        Comment

        • Sharath

          #5
          Re: call back functions...

          On Jun 28, 2:57 pm, "sameer....@gma il.com" <sameer....@gma il.com>
          wrote:
          I am looking for some comprehensive tutorials on how to write call
          back functions in C. Can anyone help me?
          There is a function pointer tutorial which includes this topic,
          you can find that here:



          -
          Sharath

          Comment

          • Chris Dollin

            #6
            Re: call back functions...

            sameer.oak@gmai l.com wrote:
            I am looking for some comprehensive tutorials on how to write call
            back functions in C. Can anyone help me?
            They're just functions that have to fit the appropriate callback
            contract; there's nothing special about them as far as C is concerned.

            What problem are you having with them?

            --
            Chris "there's a song there somewhere" Dollin

            Hewlett-Packard Limited Cain Road, Bracknell, registered no:
            registered office: Berks RG12 1HN 690597 England

            Comment

            • Clever Monkey

              #7
              Re: call back functions...

              Eric Sosman wrote:
              sameer.oak@gmai l.com wrote:
              >I am looking for some comprehensive tutorials on how to write call
              >back functions in C. Can anyone help me?
              >
              Write a callback function in the same way you write
              any other function. There is nothing "different" about a
              callback function, nothing at all. It's just a function.
              >
              That is to say, the "callback" part is how the function is used, not how
              it is defined.
              --
              clvrmnky <mailto:spamtra p@clevermonkey. org>

              Direct replies will be blacklisted. Replace "spamtrap" with my name to
              contact me directly.

              Comment

              • Richard Tobin

                #8
                Re: call back functions...

                In article <XsRgi.15474$13 .8323@nnrp.ca.m ci.com!nnrp1.uu net.ca>,
                Clever Monkey <spamtrap@cleve rmonkey.org.INV ALIDwrote:
                >>I am looking for some comprehensive tutorials on how to write call
                >>back functions in C. Can anyone help me?
                > Write a callback function in the same way you write
                >any other function. There is nothing "different" about a
                >callback function, nothing at all. It's just a function.
                >That is to say, the "callback" part is how the function is used, not how
                >it is defined.
                Not entirely. The way that it is used has implications for its
                definition.

                Callback functions are unusual in that their types are generally
                specified by a library, but their definitions are written by the user,
                and some or all of their arguments are passed in by the user. As a
                result, callbacks are commonly defined to take void * arguments
                (allowing the user some flexibility in the values that can be passed)
                where a similar function not used as a callback would probably take
                more specifically typed arguments.

                -- Richard
                --
                "Considerat ion shall be given to the need for as many as 32 characters
                in some alphabets" - X3.4, 1963.

                Comment

                • Clever Monkey

                  #9
                  Re: call back functions...

                  Richard Tobin wrote:
                  In article <XsRgi.15474$13 .8323@nnrp.ca.m ci.com!nnrp1.uu net.ca>,
                  Clever Monkey <spamtrap@cleve rmonkey.org.INV ALIDwrote:
                  >
                  >>>I am looking for some comprehensive tutorials on how to write call
                  >>>back functions in C. Can anyone help me?
                  >
                  >> Write a callback function in the same way you write
                  >>any other function. There is nothing "different" about a
                  >>callback function, nothing at all. It's just a function.
                  >
                  >That is to say, the "callback" part is how the function is used, not how
                  >it is defined.
                  >
                  Not entirely. The way that it is used has implications for its
                  definition.
                  >
                  Callback functions are unusual in that their types are generally
                  specified by a library, but their definitions are written by the user,
                  and some or all of their arguments are passed in by the user. As a
                  result, callbacks are commonly defined to take void * arguments
                  (allowing the user some flexibility in the values that can be passed)
                  where a similar function not used as a callback would probably take
                  more specifically typed arguments.
                  >
                  I see your point. Upon consideration, I realize I have experience only
                  with two varieties of callback:

                  - An function passed to a module to facilitate code generalization.
                  e.g., a way to provide a function to a module that updates a UI by
                  calling back to an API that has no knowledge of the UI specifics.

                  - A generic library call, such as a data structure deletion function, or
                  the classic sorting function.

                  In the first case we generally know what sorts of args it will take, and
                  what type (it does in the legacy code I maintain, anyway). It is just
                  who is running it, and how exactly they will use it that is unknown to
                  the provider -- the provider just provides the data in a known format.
                  In the latter we have to provide a more generic interface.

                  I'm more familiar with the former, but recently had to implement a map
                  for a public API, which required a generic dispose() function to be used
                  as a callback. I'd forgotten the subtleties.
                  --
                  clvrmnky <mailto:spamtra p@clevermonkey. org>

                  Direct replies will be blacklisted. Replace "spamtrap" with my name to
                  contact me directly.

                  Comment

                  • Eric Sosman

                    #10
                    Re: call back functions...

                    Richard Tobin wrote:
                    In article <XsRgi.15474$13 .8323@nnrp.ca.m ci.com!nnrp1.uu net.ca>,
                    Clever Monkey <spamtrap@cleve rmonkey.org.INV ALIDwrote:
                    >
                    >>>I am looking for some comprehensive tutorials on how to write call
                    >>>back functions in C. Can anyone help me?
                    >
                    >> Write a callback function in the same way you write
                    >>any other function. There is nothing "different" about a
                    >>callback function, nothing at all. It's just a function.
                    >
                    >That is to say, the "callback" part is how the function is used, not how
                    >it is defined.
                    >
                    Not entirely. The way that it is used has implications for its
                    definition.
                    >
                    Callback functions are unusual in that their types are generally
                    specified by a library, but their definitions are written by the user,
                    [...]
                    Hmmm: Would you describe main() as a callback function?

                    :-)

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

                    Comment

                    • Malcolm McLean

                      #11
                      Re: call back functions...


                      "Eric Sosman" <esosman@acm-dot-org.invalidwrot e in message
                      news:Cr2dnXv8fJ z6IhjbnZ2dnUVZ_ hSdnZ2d@comcast .com...
                      Richard Tobin wrote:
                      >In article <XsRgi.15474$13 .8323@nnrp.ca.m ci.com!nnrp1.uu net.ca>,
                      >Clever Monkey <spamtrap@cleve rmonkey.org.INV ALIDwrote:
                      >>
                      >>>>I am looking for some comprehensive tutorials on how to write call
                      >>>>back functions in C. Can anyone help me?
                      >>
                      >>> Write a callback function in the same way you write
                      >>>any other function. There is nothing "different" about a
                      >>>callback function, nothing at all. It's just a function.
                      >>
                      >>That is to say, the "callback" part is how the function is used, not how
                      >>it is defined.
                      >>
                      >Not entirely. The way that it is used has implications for its
                      >definition.
                      >>
                      >Callback functions are unusual in that their types are generally
                      >specified by a library, but their definitions are written by the user,
                      >[...]
                      >
                      Hmmm: Would you describe main() as a callback function?
                      >
                      :-)
                      >
                      Yes. The shell calls it.

                      --
                      Free games and programming goodies.



                      Comment

                      • Flash Gordon

                        #12
                        Re: call back functions...

                        Malcolm McLean wrote, On 30/06/07 09:41:
                        >
                        "Eric Sosman" <esosman@acm-dot-org.invalidwrot e in message
                        news:Cr2dnXv8fJ z6IhjbnZ2dnUVZ_ hSdnZ2d@comcast .com...
                        >Richard Tobin wrote:
                        >>In article <XsRgi.15474$13 .8323@nnrp.ca.m ci.com!nnrp1.uu net.ca>,
                        >>Clever Monkey <spamtrap@cleve rmonkey.org.INV ALIDwrote:
                        >>>
                        >>>>>I am looking for some comprehensive tutorials on how to write call
                        >>>>>back functions in C. Can anyone help me?
                        >>>
                        >>>> Write a callback function in the same way you write
                        >>>>any other function. There is nothing "different" about a
                        >>>>callback function, nothing at all. It's just a function.
                        >>>
                        >>>That is to say, the "callback" part is how the function is used, not
                        >>>how it is defined.
                        >>>
                        >>Not entirely. The way that it is used has implications for its
                        >>definition.
                        >>>
                        >>Callback functions are unusual in that their types are generally
                        >>specified by a library, but their definitions are written by the user,
                        >>[...]
                        >>
                        > Hmmm: Would you describe main() as a callback function?
                        >>
                        > :-)
                        >>
                        Yes. The shell calls it.
                        That is not always true and in any case does not make it a callback.
                        However, Richard did not say that the aspects he was specifying were
                        unique to callbacks.
                        --
                        Flash Gordon

                        Comment

                        Working...