Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!brl-sem!ron From: ron@brl-sem.UUCP Newsgroups: comp.lang.c Subject: Re: Why pass structs? (not struct pointers) Message-ID: <661@brl-sem.ARPA> Date: Fri, 27-Feb-87 13:54:52 EST Article-I.D.: brl-sem.661 Posted: Fri Feb 27 13:54:52 1987 Date-Received: Sun, 1-Mar-87 09:26:50 EST References: <3346@cisunx.UUCP> Distribution: na Organization: Electronic Brain Research Lab Lines: 28 In article <3346@cisunx.UUCP>, ed360463@cisunx.UUCP (wartell m) writes: > > 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. Well your hopes are wrong. There are many machines that can not push anything on the stack in one operation. Even more enlighted machines with autodecrement indexed stack pointers or push instructions can't push the larger datatypes on the stack with one instruction. I'm not sure what point you are trying to make. There is a lot of stuff in the subroutine call sequence that is a lot more vulnerable to interruption than a single argument push. > 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? Mostly because it seemed that it would be silly not to. You can push and return any other data type (well almost any other, unions still don't work mostly). The only reason STRUCTS were initially left out was because they weren't easy to do. -Ron