← Back to context

Comment by jibal

10 hours ago

According to https://www.nokia.com/bell-labs/about/dennis-m-ritchie/chist..., which is authoritative:

> During 1973-1980, the language grew a bit: the type structure gained unsigned, long, union, and enumeration types, and structures became nearly first-class objects (lacking only a notation for literals).

And

> By 1982 it was clear that C needed formal standardization. The best approximation to a standard, the first edition of K&R, no longer described the language in actual use; in particular, it mentioned neither the void or enum types. While it foreshadowed the newer approach to structures, only after it was published did the language support assigning them, passing them to and from functions, and associating the names of members firmly with the structure or union containing them. Although compilers distributed by AT&T incorporated these changes, and most of the purveyors of compilers not based on pcc quickly picked up them up, there remained no complete, authoritative description of the language.

So passing structs entered the language before C89, and possibly was available in some compilers by 1979. I was very active in C during this period and was a member of X3J11 (I happen to be the first person ever to vote to standardize C, due to alphabetical order), but unfortunately I'm not able to pin down the timing from my own memory.

P.S. Page of 121 of K&R C, first edition, says "The essential rules are that the only operations that you can perform on a structure are take its address with c, and access one of its members. This implies that structures may not be assigned to or copied as a unit, and that they cannot be passed to or returned from functions. (These restrictions will be removed in forthcoming versions.)"

So they were already envisioning passing structs to functions in 1978.

Yeah, I don't think I claimed that these things weren't "envisioned" in 1979. My claim was that they most certainly weren't "common practice" in 1979.

In my mind, they didn't exist yet, and certainly the 1978 definition of C that I read and you also cite confirms this: "they cannot be passed to or returned from functions". Not much time between 1978 and 1979, so while that's possible it doesn't seem particularly likely.

My first C compiler, Manx Aztec C for the Amiga (obviously from the mid 1980s) didn't support structures as function arguments, and only got them with a later upgrade that supported ANSI C.

The 2nd edition of "The C Programming Language" from 1988 also describes ANSI C (at least that's what it says on the cover), so I don't see any documentation that points to C with structures as function arguments in the 1979 timeframe.

So I think even my less important claim, that structure passing came about with ANSI C, is pretty solid, even if there may have been isolated compilers that supported structure passing before that.

And never mind the "common practice".