home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 19037 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  1.4 KB

  1. Path: sparky!uunet!news.uiowa.edu!hobbes.physics.uiowa.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!gatech!destroyer!ncar!noao!amethyst!organpipe.uug.arizona.edu!news
  2. From: dave@cs.arizona.edu (Dave Schaumann)
  3. Newsgroups: comp.lang.c
  4. Subject: Parameter passing & data abstraction
  5. Message-ID: <1992Dec30.184135.1963@organpipe.uug.arizona.edu>
  6. Date: 30 Dec 92 18:41:35 GMT
  7. Sender: news@organpipe.uug.arizona.edu
  8. Reply-To: dave@cs.arizona.edu (Dave Schaumann)
  9. Organization: University of Arizona
  10. Lines: 20
  11.  
  12. It has come to me that C's mechanisms for parameter passing are less than
  13. wonderful.  For instance, in defining some data structure, my typical
  14. stratagy is to create a .h file with the struct definition, appropriate
  15. typedefs, and #defines for simple functions.
  16.  
  17. The root of the problem is that I want to pretend that macros are really
  18. in-line functions.  However, "macro functions" display "call by reference"
  19. behavior, while real functions have call by value behavior.
  20.  
  21. One solution is to always pass pointers -- in effect, change the default
  22. parameter behavior (for structs, anyway) to be call-by-reference.
  23.  
  24. Another would be to switch to C++, but I'm not especially keen to do that,
  25. in part because the resulting executable (at least for g++) tend to be
  26. 300+K in size, even for fairly simple programs.
  27.  
  28. Anyone have further thoughts on this?
  29.  
  30. -- 
  31. Dave Schaumann            dave@cs.arizona.edu
  32.