Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!rochester!pt.cs.cmu.edu!cadre!pitt!cisunx!ed360463 From: ed360463@cisunx.UUCP Newsgroups: comp.lang.c Subject: Why pass structs? (not struct pointers) Message-ID: <3346@cisunx.UUCP> Date: Thu, 26-Feb-87 23:35:17 EST Article-I.D.: cisunx.3346 Posted: Thu Feb 26 23:35:17 1987 Date-Received: Sun, 1-Mar-87 11:16:01 EST Reply-To: ed360463@cisunx.UUCP (wartell m) Distribution: na Organization: Univ. of Pittsburgh, Comp & Info Sys Lines: 25 I have been aware of the post V7 C compilers passing and returning structs from procedures, and I am curious as to why. Passing structures as a whole seems to violate my impression of the nature of C. I feel that a good reason for passing arrays by reference (yes, I know that the pointer is passed by value :-) is to save an enormous ammount of stack and CPU time. To pass a structure by value seems to require an arbitrarily large amount of stack; but more importantly, non-atomic stack operations. That is, that I can push a long, int, char or any pointer with (hopefully) one machine-op. To pass a structure would require a number of pushes, a block-copy-op, or some looping copy code. I imagine that the people who added this to C had good reason, so could someone please tell me what I am missing or have gotten wrong? Thank you -- matt wartell university of pittsburgh {the known world}!pitt!cisunx!ed360463