home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13052 < prev    next >
Encoding:
Text File  |  1992-08-29  |  2.0 KB  |  49 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!usc!elroy.jpl.nasa.gov!decwrl!borland.com!pete
  3. From: pete@genghis.borland.com (Pete Becker)
  4. Subject: Re: Callbacks - C++ needs an extension?
  5. Message-ID: <1992Aug29.161356.16729@genghis.borland.com>
  6. Originator: pete@genghis.borland.com
  7. Keywords: callback event eventdriven extension
  8. Sender: news@borland.com (News Admin)
  9. Organization: Borland International
  10. References: <1992Aug28.165108.17479@isy.liu.se>
  11. Date: Sat, 29 Aug 1992 16:13:56 GMT
  12. Lines: 35
  13.  
  14. In article <1992Aug28.165108.17479@isy.liu.se> svan@isy.liu.se writes:
  15. >Hi guys!
  16. >
  17. >Maybe some of you have, like me, done some windowprogramming in
  18. >C++. There are a lot of toolkits to choose from, but whatever
  19. >you choose, wether it is a C++-package like TNT or a C-package
  20. >like xview, you'll probably stumble upon the notion of call-
  21. >backs.
  22. >
  23. >Callbacks are essencially a functionpointer you deliver to 
  24. >the windowing toolkit when creating a widget, for instance 
  25. >a button. This function is then supposed to be called when
  26. >the user have taken some action, like pressing the button.
  27. >
  28. >Their existance is motified by the nature of event-driven
  29. >programming and that it is most unpractical to have to edit
  30. >sourcecode in the toolkit when you want a special function in
  31. >your source to be called.
  32. >
  33. >Most often a button is connected to some sort of other
  34. >object, like a window, and it is most often the window that
  35. >knows how to response when the button is pressed.
  36. >
  37. >The problem is that it seems impossible in C++ to implement
  38. >a callback strategy which calls this window-object directly...
  39. >
  40.  
  41.     The problem is not in C++ but in libraries that constrain callback
  42. functions to look like ordinary C functions.  Such libraries are old 
  43. technology, and making newer techniques work will always require a certain
  44. amount of work.
  45.     The most straightforward solution is to work with the library and
  46. provide a callback function that examines the message being sent and forwards
  47. it to the appropriate recipient.
  48.     -- Pete
  49.