Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Structures Message-ID: <1990Mar5.183244.1013@utzoo.uucp> Organization: U of Toronto Zoology References: <14302@reed.UUCP> <4390@daffy.cs.wisc.edu> Date: Mon, 5 Mar 90 18:32:44 GMT In article <4390@daffy.cs.wisc.edu> schaut@cat9.cs.wisc.edu (Rick Schaut) writes: >| 2] It seems that passing a structure-by-value is illegal under this rule. >| Why this limitation in the original C? > >Because C was originaly written for a DEC PDP11 which only had 64K of >ram. Under those conditions, passing structures by value simply takes >up too much stack space. You'd be amazed at how many programs used to fit comfortably in 64KB before people with financial interests in memory sales got hold of them... The first compiler with struct passing and returning was Dennis's pdp11 one, which had many happy users for a long time. >It's a warning because most people (including me) still try to restrict >themselves to passing only pointers to structures. I'm not even sure why >you'd ever want to pass a structure by value... The main motive for this, in my experience, is when you're essentially building your own data types (complex numbers in sci/eng number-crunching, two-dimensional coordinates in graphics, etc.) and want to treat them as if they were ordinary values. Passing pointers gets troublesome very quickly in such situations. -- MSDOS, abbrev: Maybe SomeDay | Henry Spencer at U of Toronto Zoology an Operating System. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu