home *** CD-ROM | disk | FTP | other *** search
- 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
- From: dave@cs.arizona.edu (Dave Schaumann)
- Newsgroups: comp.lang.c
- Subject: Parameter passing & data abstraction
- Message-ID: <1992Dec30.184135.1963@organpipe.uug.arizona.edu>
- Date: 30 Dec 92 18:41:35 GMT
- Sender: news@organpipe.uug.arizona.edu
- Reply-To: dave@cs.arizona.edu (Dave Schaumann)
- Organization: University of Arizona
- Lines: 20
-
- It has come to me that C's mechanisms for parameter passing are less than
- wonderful. For instance, in defining some data structure, my typical
- stratagy is to create a .h file with the struct definition, appropriate
- typedefs, and #defines for simple functions.
-
- The root of the problem is that I want to pretend that macros are really
- in-line functions. However, "macro functions" display "call by reference"
- behavior, while real functions have call by value behavior.
-
- One solution is to always pass pointers -- in effect, change the default
- parameter behavior (for structs, anyway) to be call-by-reference.
-
- Another would be to switch to C++, but I'm not especially keen to do that,
- in part because the resulting executable (at least for g++) tend to be
- 300+K in size, even for fairly simple programs.
-
- Anyone have further thoughts on this?
-
- --
- Dave Schaumann dave@cs.arizona.edu
-